Java Basics
Java Basics - Important Points
16. | Which of the following is a wrapper class in Java? |
---|
A. int
B. boolean
C. double
D. string
View Answer Discuss Work SpaceAnswer: option b
Explanation:
17. | Which of the following is NOT a valid way to create a thread in Java? |
---|
A. Implementing the Runnable interface
B. Extending the Thread class
C. Calling the start() method on a Thread object
D. Creating a new instance of the Thread class
View Answer Discuss Work SpaceAnswer: option c
Explanation:
18. | What is the output of the following code? public class Test { public static void main(String args[]) { int x = 10; int y = 5; if(x > y) { System.out.println("x is greater than y"); } else { System.out.println("x is less than or equal to y"); } } } |
---|
A. x is greater than y
B. x is less than or equal to y
C. Both statements are printed
D. No output
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The condition x > y is true, so the output is "x is greater than y".
19. | Which of the following is NOT a valid exception handling keyword in Java? |
---|
A. try
B. catch
C. finally
D. handle
View Answer Discuss Work SpaceAnswer: option d
Explanation:
20. | What is the output of the following code? public class Test { public static void main(String args[]) { int x = 10; int y = 5; int z = x + y; System.out.println("The sum of " + x + " and " + y + " is " + z); } } |
---|
A. The sum of 10 and 5 is 15
B. The sum of x and y is z
C. The sum of x and y is 15
D. No output
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The values of x, y, and z are used to create a string that is printed to the console.