-
Q1 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { System.out.println("Hello, World!"); } }ExplanationCorrect option: B) Hello, World! -
Q2 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 10; System.out.println(x + y); } }ExplanationCorrect option: A) 15 -
Q3 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; System.out.println(x++); System.out.println(x); } }ExplanationCorrect option: C) 5 6 -
Q4 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; System.out.println(++x); } }ExplanationCorrect option: B) 6 -
Q5 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; System.out.println(x--); System.out.println(x); } }ExplanationCorrect option: C) 5 4 -
Q6 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; System.out.println(--x); } }ExplanationCorrect option: B) 4 -
Q7 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; x += 10; System.out.println(x); } }ExplanationCorrect option: C) 15 -
Q8 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; x -= 5; System.out.println(x); } }ExplanationCorrect option: A) 5 -
Q9 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; x *= 2; System.out.println(x); } }ExplanationCorrect option: B) 10 -
Q10 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; x /= 2; System.out.println(x); } }ExplanationCorrect option: A) 5 -
Q11 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; x %= 3; System.out.println(x); } }ExplanationCorrect option: B) 2 -
Q12 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; System.out.println(x > 5); } }ExplanationCorrect option: A) true -
Q13 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; System.out.println(x < 5); } }ExplanationCorrect option: B) false -
Q14 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; System.out.println(x == 10); } }ExplanationCorrect option: A) true -
Q15 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; System.out.println(x != 10); } }ExplanationCorrect option: B) false -
Q16 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; System.out.println(x >= 10); } }ExplanationCorrect option: A) true -
Q17 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; System.out.println(x <= 5); } }ExplanationCorrect option: B) false -
Q18 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 10; System.out.println(x > y); } }ExplanationCorrect option: B) false -
Q19 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 10; System.out.println(x < y); } }ExplanationCorrect option: A) true
-
Q20 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 5; System.out.println(x == y); } }ExplanationCorrect option: A) true -
Q21 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 10; System.out.println(x != y); } }ExplanationCorrect option: A) true -
Q22 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 10; System.out.println(x >= y); } }ExplanationCorrect option: B) false -
Q23 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 10; int y = 5; System.out.println(x <= y); } }ExplanationCorrect option: B) false -
Q24 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 5; System.out.println(x == y && x > 0); } }ExplanationCorrect option: A) true -
Q25 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 10; System.out.println(x < y || x > 0); } }ExplanationCorrect option: A) true -
Q26 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; int y = 10; System.out.println(!(x > y)); } }ExplanationCorrect option: A) true -
Q27 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; if (x > 0) { System.out.println("Positive"); } } }ExplanationCorrect option: A) Positive -
Q28 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = -5; if (x > 0) { System.out.println("Positive"); } else { System.out.println("Negative"); } } }ExplanationCorrect option: B) Negative -
Q29 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; if (x > 0) { System.out.println("Positive"); } else { System.out.println("Negative"); } } }ExplanationCorrect option: A) Positive -
Q30 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; if (x > 0) { System.out.println("Positive"); } else if (x < 0) { System.out.println("Negative"); } else { System.out.println("Zero"); } } }ExplanationCorrect option: A) Positive -
Q31 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = -5; if (x > 0) { System.out.println("Positive"); } else if (x < 0) { System.out.println("Negative"); } else { System.out.println("Zero"); } } }ExplanationCorrect option: B) Negative -
Q32 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; if (x > 0) { System.out.println("Positive"); } else if (x < 0) { System.out.println("Negative"); } else { System.out.println("Zero"); } } }ExplanationCorrect option: C) Zero -
Q33 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 5; switch (x) { case 1: System.out.println("One"); break; case 2: System.out.println("Two"); break; case 3: System.out.println("Three"); break; case 4: System.out.println("Four"); break; case 5: System.out.println("Five"); break; default: System.out.println("Invalid"); } } }ExplanationCorrect option: D) Five -
Q34 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 3; switch (x) { case 1: System.out.println("One"); break; case 2: System.out.println("Two"); break; case 3: System.out.println("Three"); break; default: System.out.println("Invalid"); } } }ExplanationCorrect option: C) Three -
Q35 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 6; switch (x) { case 1: System.out.println("One"); break; case 2: System.out.println("Two"); break; case 3: System.out.println("Three"); break; default: System.out.println("Invalid"); } } }ExplanationCorrect option: D) Invalid -
Q36 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 2; int y = 0; switch (x) { case 1: y = 1; break; case 2: y = 2; break; case 3: y = 3; break; default: y = 4; } System.out.println(y); } }ExplanationCorrect option: C) 2 -
Q37 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 4; int y = 0; switch (x) { case 1: y = 1; break; case 2: y = 2; break; case 3: y = 3; break; default: y = 4; } System.out.println(y); } }ExplanationCorrect option: D) 4 -
Q38 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 2; switch (x) { case 1: System.out.println("One"); break; case 2: System.out.println("Two"); case 3: System.out.println("Three"); break; default: System.out.println("Invalid"); } } }ExplanationCorrect option: B) Two Three
-
Q39 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; for (int i = 0; i< 5; i++) { x += i; } System.out.println(x); } }ExplanationCorrect option: B) 10 -
Q40 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; for (int i = 1; i<= 5; i++) { x += i; } System.out.println(x); } }ExplanationCorrect option: C) 15 -
Q41 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 1; for (int i = 1; i<= 3; i++) { x *= i; } System.out.println(x); } }ExplanationCorrect option: B) 6 -
Q42 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; int i = 0; while (i< 5) { x += i; i++; } System.out.println(x); } }ExplanationCorrect option: B) 10 -
Q43 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; int i = 1; while (i<= 5) { x += i; i++; } System.out.println(x); } }ExplanationCorrect option: C) 15 -
Q44 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 1; int i = 1; while (i<= 3) { x *= i; i++; } System.out.println(x); } }ExplanationCorrect option: B) 6 -
Q45 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; int i = 0; do { x += i; i++; } while (i< 5); System.out.println(x); } }ExplanationCorrect option: B) 10 -
Q46 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; int i = 1; do { x += i; i++; } while (i<= 5); System.out.println(x); } }ExplanationCorrect option: C) 15 -
Q47 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 1; int i = 1; do { x *= i; i++; } while (i<= 3); System.out.println(x); } }ExplanationCorrect option: B) 6 -
Q48 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; for (int i = 1; i<= 5; i++) { if (i % 2 == 0) { continue; } x += i; } System.out.println(x); } }ExplanationCorrect option: A) 9 -
Q49 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 0; for (int i = 1; i<= 5; i++) { if (i == 3) { break; } x += i; } System.out.println(x); } }ExplanationCorrect option: A) 3 -
Q50 Easy
What will be the output of the following code?
public class Test { public static void main(String[] args) { int x = 1; for (int i = 1; i<= 3; i++) { x *= i; } System.out.println(x); } }ExplanationCorrect option: B) 6 -
Q51 Easy
What will be the output of the following code?
class A { void display() { System.out.println("A"); } } class B extends A { void display() { System.out.println("B"); } public static void main(String[] args) { B obj = new B(); obj.display(); } }ExplanationCorrect option: B) B -
Q52 Easy
What will be the output of the following code?
class A { A() { System.out.println("A"); } } class B extends A { B() { System.out.println("B"); } public static void main(String[] args) { B obj = new B(); } }ExplanationCorrect option: C) AB -
Q53 Easy
What will be the output of the following code?
class A { static void display() { System.out.println("A"); } } class B extends A { static void display() { System.out.println("B"); } public static void main(String[] args) { A obj = new B(); obj.display(); } }ExplanationCorrect option: A) A -
Q54 Easy
What will be the output of the following code?
class A { void display() { System.out.println("A"); } } class B extends A { void display() { System.out.println("B"); } } class C extends B { void display() { System.out.println("C"); } public static void main(String[] args) { C obj = new C(); obj.display(); } }ExplanationCorrect option: C) C -
Q55 Easy
What will be the output of the following code?
class A { A() { System.out.println("A"); } } class B extends A { B() { System.out.println("B"); } } class C extends B { C() { System.out.println("C"); } public static void main(String[] args) { C obj = new C(); } }ExplanationCorrect option: C) ABC -
Q56 Easy
What will be the output of the following code?
class A { static void display() { System.out.println("A"); } } class B extends A { static void display() { System.out.println("B"); } } class C extends B { static void display() { System.out.println("C"); } public static void main(String[] args) { A obj = new C(); obj.display(); } }ExplanationCorrect option: A) A -
Q57 Easy
What will be the output of the following code?
interface A { void display(); } class B implements A { public void display() { System.out.println("B"); } public static void main(String[] args) { B obj = new B(); obj.display(); } }ExplanationCorrect option: B) B
-
Q58 Easy
What will be the output of the following code?
interface A { void display(); } interface B extends A { void show(); } class C implements B { public void display() { System.out.println("Display"); } public void show() { System.out.println("Show"); } public static void main(String[] args) { C obj = new C(); obj.display(); obj.show(); } }ExplanationCorrect option: C) Display Show -
Q59 Easy
What will be the output of the following code?
interface A { default void display() { System.out.println("A"); } } class B implements A { public static void main(String[] args) { B obj = new B(); obj.display(); } }ExplanationCorrect option: A) A -
Q60 Easy
What will be the output of the following code?
interface A { default void display() { System.out.println("A"); } } interface B { default void display() { System.out.println("B"); } } class C implements A, B { public void display() { A.super.display(); } public static void main(String[] args) { C obj = new C(); obj.display(); } }ExplanationCorrect option: A) A -
Q61 Easy
What will be the output of the following code?
class Test { static void display() { System.out.println("Static method"); } void show() { System.out.println("Instance method"); } public static void main(String[] args) { Test obj = new Test(); obj.display(); obj.show(); } }ExplanationCorrect option: A) Static method Instance method -
Q62 Easy
What will be the output of the following code?
class Test { static void display() { System.out.println("Static method"); } void show() { System.out.println("Instance method"); } public static void main(String[] args) { Test.display(); } }ExplanationCorrect option: A) Static method -
Q63 Easy
What will be the output of the following code?
class Test { static void display() { System.out.println("Static method"); } void show() { System.out.println("Instance method"); } public static void main(String[] args) { Test obj = new Test(); obj.show(); } }ExplanationCorrect option: B) Instance method -
Q64 Easy
What will be the output of the following code?
class Test { static { System.out.println("Static block"); } { System.out.println("Instance block"); } Test() { System.out.println("Constructor"); } public static void main(String[] args) { new Test(); } }ExplanationCorrect option: D) Static block Instance block Constructor -
Q65 Easy
What will be the output of the following code?
class Test { static { System.out.println("Static block"); } { System.out.println("Instance block"); } Test() { System.out.println("Constructor"); } public static void main(String[] args) { new Test(); new Test(); } }ExplanationCorrect option: A) Static block Instance block Constructor Instance block Constructor -
Q66 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; public static void main(String[] args) { Test obj = new Test(); System.out.println(obj.x); System.out.println(obj.y); } }ExplanationCorrect option: A) 10 20 -
Q67 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; public static void main(String[] args) { System.out.println(Test.x); System.out.println(new Test().y); } }ExplanationCorrect option: A) 10 20 -
Q68 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; void display() { System.out.println(x); System.out.println(y); } public static void main(String[] args) { new Test().display(); } }ExplanationCorrect option: A) 10 20 -
Q69 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; void display() { System.out.println(x); System.out.println(y); } public static void main(String[] args) { Test obj1 = new Test(); Test obj2 = new Test(); obj1.display(); obj2.display(); } }ExplanationCorrect option: A) 10 20 10 20 -
Q70 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; static void display() { System.out.println(x); } public static void main(String[] args) { display(); } }ExplanationCorrect option: A) 10 -
Q71 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; static void display() { System.out.println(x); } public static void main(String[] args) { Test.display(); } }ExplanationCorrect option: A) 10 -
Q72 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; static void display() { System.out.println(x); } public static void main(String[] args) { new Test().display(); } }ExplanationCorrect option: A) 10 -
Q73 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; void display() { System.out.println(x); System.out.println(y); } public static void main(String[] args) { Test obj = new Test(); obj.display(); } }ExplanationCorrect option: A) 10 20 -
Q74 Easy
What will be the output of the following code?
class Test { static int x = 10; int y = 20; static void display() { System.out.println(x); } public static void main(String[] args) { Test obj = new Test(); obj.display(); } }ExplanationCorrect option: A) 10