Q1. Given:
What is the result?
A. 10 20 30 40
B. 0 0 30 40
C. Compilation fails
D. An exception is thrown at runtime
Answer: A
Q2. Given:
What is the result?
A. 10:20
B. 0:20
C. Compilation fails at line n1
D. Compilation fails at line n2
Answer: D
Q3. Given the following classes:
Which two options fail to compile when placed at line n1 of the main method?
A. employee.salary = 50_000;
B. director.salary = 80_000;
C. employee.budget = 200_000;
D. manager.budget = 1_000_000;
E. manager.stockOption = 500;
F. director.stockOptions = 1_000;
Answer: C,E
Q4. Given the code fragment:
What is the result?
A. A B C Work done
B. A B C D Work done
C. A Work done
D. Compilation fails
Answer: C
Q5. Given:
public class X {
static int i;
int j;
public static void main(String[] args) {
X x1 = new X();
X x2 = new X();
x1.i = 3;
x1.j = 4;
x2.i = 5;
x2.j = 6;
System.out.println(
x1.i + " "+
x1.j + " "+
x2.i + " "+
x2.j);
}
}
What is the result?
A. 3 4 5 6
B. 3 4 3 6
C. 5 4 5 6
D. 3 6 4 6
Answer: C
Q6. Given the code fragment:
What is the result?
A. Values are : [EE, ME]
B. Values are : [EE, EE, ME]
C. Values are : [EE, ME, EE]
D. Values are : [SE, EE, ME, EE]
E. Values are : [EE, ME, SE, EE]
Answer: E