Below Advanced Java quiz are Multiple Choice Questions (MCQs) type Quiz. These Advanced Java MCQ Questions helps you to refresh your Advanced Java, you can see the correct option by clicking on it. .
1. What is the correct declaration of an abstract method
public abstract method();
public void abstract method();
public abstract void method();
public final abstract void method();
2. Which one of the following statement is not true about the collection interface?
all methods defined in set interface are also defined in collection interface
list interface extends collection interface
set interface extends collection interface
all methods defined in list interface are also defined in collection interface
3. Which are legal declarations? (Choose all that apply)
short x [];
short [] y;
short[5] x2;
All of above
4. What is the type and value of the following expression? (Notice the integerdivision)-4 + 1/2 + 2*-3 + 5.0
int -5
double-4.5
int-4
double-5.0
5. Consider the following class definition: public class MyClass { private int value; public void setValue(int i){ / code / } // Other methods… } The method setValue assigns the value of i to the instance field value. What could you write for the implementation of setValue?
value = i;
this.value = i;
value == i;
Both (A) and (B) and above
6. Which of the following variable declaration would NOT compile in a java program?
int var;
int VAR;
int var1;
int 1_var;.
7. What will be printed as the output of the following program? public class testincr { public static void main(String args[]) { int i = 0; i = i++ + i; System.out.println(“I = ” +i); } }
I=0
I=1
I=2
Error
8. Predict the output of following Java Programs. // filename Main.java class Test { protected int x, y; } class Main { public static void main(String args[]) { Test t = new Test(); System.out.println(t.x + " " + t.y); } }
1,1
1,2
0,0
Error
9. Predict the output of following Java programs. package main; class Base { public void Print() { System.out.println("Base"); } } class Derived extends Base { public void Print() { System.out.println("Derived"); } } class Main{ public static void DoPrint( Base o ) { o.Print(); } public static void main(String[] args) { Base x = new Base(); Base y = new Derived(); Derived z = new Derived(); DoPrint(x); DoPrint(y); DoPrint(z); } }
Base, Derived, Derived
Derived, Derived ,Derived
Derived, Derived, Base
None
10. which one of these events will cause the thread to die?
on calling the sleep() method.
when the execution of the run() method ends
when the execution of the start() method ends
on calling the wait() method
11. Use the following declaration and initialization to evaluate the Java expressions int a = 2, b = 3, c = 4, d = 5; float k = 4.3f; System.out.println (c=c++);
2
4
5
8
12. Which of the followings are the types of JIT?
Pre-JIT
Econo-JIT
Normal-JIT
All of the above
13. which of the following is wrapper class in java