-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_quad.txt
More file actions
77 lines (64 loc) · 2.04 KB
/
Copy pathtest_quad.txt
File metadata and controls
77 lines (64 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class Point {
int x;
int y;
void setX(int v) {
x = v;
}
int getX() {
return x;
}
}
class TestCombined {
public static void main(String[] args) {
// Variable declarations
int a = 10;
b = 5;
sum = 0;
int i;
boolean result;
Point p = new Point();
// Arithmetic expressions (simple and complex)
c = a + b; // Simple addition
a = c - b; // Simple subtraction
k = (a + b) * (c - d) / (c * 2); // Complex expression
// Conditional expressions
result = a < b; // Less than
result = a > b; // Greater than
result = a != b; // Not equal
result = a <= b; // Less than or equal
result = a >= b; // Greater than or equal
result = (a < b) && (a != b); // Logical AND
result = (a > b) || (a == b); // Logical OR
result = (a * 2 == b) || (c / 3 <= a + 1) && !(b != 10); // Complex conditional
// Object manipulation
p.x = 5; // Set field
p.y = 10; // Set field
a = p.x; // Get field
b = p.y; // Get field
// Method calls
p.setX(); // Call void method
k = p.getX(); // Call method with return
// If statement
if (a < b) {
result = true;
}
// If-else-if-else statement
if (a + b >= c && !(b == 10)) {
result = false;
} else if ((a * 2 <= b + c) || (c / 3 > a)) {
result = true;
} else {
result = false;
}
// For loop
for (i = 0; i < 5; i++) {
sum = sum + i;
}
// While loop
i = 0;
while (i < 5) {
sum = sum + i;
i++;
}
}
}