- What will be printed?
1 System.out.println(2 + 3 * 4); View Answer
Correct answer: B — 14
- Which of the following is not a primitive type in Java?
View Answer
Correct answer: C — String
- What will be printed?
1 System.out.println("Hello" + "World"); View Answer
Correct answer: B — HelloWorld
- Which keyword is used to define a constant in Java?
View Answer
Correct answer: B — final
- What will be printed?
1 int x = 5; 2 System.out.println(x++); View Answer
Correct answer: A — 5
- Which of the following is the default value of a boolean in Java?
View Answer
Correct answer: B — false
- What will be printed?
1 int a = 10; 2 int b = 20; 3 System.out.println(a > b); View Answer
Correct answer: B — false
- Which of the following is used to terminate a statement in Java?
View Answer
Correct answer: B — ;
- What will be printed?
1 System.out.println(10/3); View Answer
Correct answer: A — 3
- Which of the following is the entry point of a Java program?
View Answer
Correct answer: B — public static void main(String[] args)
- What will be printed?
1 System.out.println(5 == 5); View Answer
Correct answer: A — true
- Which of the following is used to allocate memory dynamically in Java?
View Answer
Correct answer: B — new
- What will be printed?
1 System.out.println("Java".length()); View Answer
Correct answer: B — 4
- Which of the following is not a valid access modifier in Java?
View Answer
Correct answer: D — internal
- What will be printed?
1 System.out.println(10 % 3); View Answer
Correct answer: A — 1
- Which of the following is used to compare two strings in Java?
View Answer
Correct answer: B — equals()
- What will be printed?
1 System.out.println("A" + 1); View Answer
Correct answer: A — A1
- Which of the following is the default value of an int in Java?
View Answer
Correct answer: A — 0
- What will be printed?
1 System.out.println(true && false); View Answer
Correct answer: B — false
- Which of the following is used to handle exceptions in Java?
View Answer
Correct answer: A — try-catch
- What will be printed?
1 System.out.println(2 << 2); View Answer
Correct answer: B — 8
- Which of the following is used to stop a loop in Java?
View Answer
Correct answer: A — break
- What will be printed?
1 System.out.println("abc".toUpperCase()); View Answer
Correct answer: B — ABC
- Which of the following is used to define a package in Java?
View Answer
Correct answer: A — package
- What will be printed?
1 System.out.println(5/2.0); View Answer
Correct answer: B — 2.5
- Which of the following is used to create a thread in Java?
View Answer
Correct answer: C — Both A and B
- What will be printed?
1 System.out.println("Java".charAt(2)); View Answer
Correct answer: C — v
- Which of the following is used to import classes in Java?
View Answer
Correct answer: B — import
- What will be printed?
1 System.out.println(10 == 10.0); View Answer
Correct answer: A — true
- Which of the following is used to define an interface in Java?
View Answer
Correct answer: A — interface
- What will be printed?
1 System.out.println("Hello".concat("World")); View Answer
Correct answer: B — HelloWorld
- Which of the following is used to exit from a program in Java?
View Answer
Correct answer: B — System.exit()
- What will be printed?
1 System.out.println(3 > 2 ? "Yes" : "No"); View Answer
Correct answer: A — Yes
- Which of the following is used to define a class in Java?
View Answer
Correct answer: A — class
- What will be printed?
1 System.out.println("Java".equals("JAVA")); View Answer
Correct answer: B — false
- Which of the following is used to define a constructor in Java?
View Answer
Correct answer: A — Same name as class
- What will be printed?
1 System.out.println("abc".replace("a","z")); View Answer
Correct answer: A — zbc
- Which of the following is used to define a constant reference in Java?
View Answer
Correct answer: A — final
- What will be printed?
1 System.out.println(7/2); View Answer
Correct answer: A — 3
- Which of the following is used to create an object in Java?
View Answer
Correct answer: A — new
- What will be printed?
1 System.out.println("Java".toLowerCase()); View Answer
Correct answer: A — java
- Which of the following is used to define inheritance in Java?
View Answer
Correct answer: A — extends
- What will be printed?
1 System.out.println(2 == 2.0); View Answer
Correct answer: A — true
- Which of the following is used to define polymorphism in Java?
View Answer
Correct answer: A — Overloading and Overriding
- What will be printed?
1 System.out.println("Hello".indexOf("l")); View Answer
Correct answer: B — 2
- Which of the following is used to define abstraction in Java?
View Answer
Correct answer: C — Both A and B
- What will be printed?
1 System.out.println("Java".substring(1,3)); View Answer
Correct answer: B — av
- Which of the following is used to define encapsulation in Java?
View Answer
Correct answer: A — private variables with public getters/setters
- What will be printed?
1 System.out.println("abc".equalsIgnoreCase("ABC")); View Answer
Correct answer: A — true
- Which of the following is used to define multiple inheritance in Java?
View Answer
Correct answer: B — interface implementation