Java Questions Bvrit v1.3
Java Questions Bvrit v1.3
int i = 0;
int j = 7;
a) 0 7; 1 6; 2 5; 3 4; b) 1 7; 2 6; 3 5; 4 4;
c) 1 6; 2 5; 3 4; d) throws Exception
OCA Practice Test 2 Java 2
5. What is output?
public class Test {
static { System.out.print(" static"); }
{ System.out.print(" instance"); }
public Test () {
System.out.print(" constr");
}
public static void main(String args[]) {
System.out.print(" main");
Test t = new Test();
OCA Practice Test 2 Java 4
}
}
a) static instance main constr b) static main instance constr
c) static constr constr main d) Will not compile
7. What is output?
public class Test {
public static void main(String[] args) {
int[] arr = {3,4,5,4,5,6};
for (int i : arr) {
System.out.print(arr[i-1] + " ");
}
}
}
a) Compile error b) 3,4,5,4,5,6 c) 5 4 5 4 5 6 d) ArrayIndexOutOfBoundsException
OCA Practice Test 2 Java 5
A. Cannot be instantiated