Java Basics
Java Basics - Important Points
11. | Which of the following is NOT a control statement in Java? |
---|
A. if
B. while
C. switch
D. string
View Answer Discuss Work SpaceAnswer: option d
Explanation:
12. | What is the output of the following code? public class Test { public static void main(String args[]) { int x = 10; int y = 20; System.out.println(x < y && x > 5); } } |
---|
A. 1
B. 0
C. 1
D. 0
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The logical AND operator (&&) returns true if both operands are true. In this case, x is less than y and greater than 5, so the output is true.
13. | Which of the following is NOT a valid access modifier in Java? |
---|
A. public
B. private
C. protected
D. static
View Answer Discuss Work SpaceAnswer: option d
Explanation:
14. | What is the output of the following code? public class Test { public static void main(String args[]) { for(int i = 0; i < 5; i++) { System.out.println(i); } } } |
---|
A. 0 1 2 3 4
B. 1 2 3 4 5
C. 0 1 2 3 4 5
D. Infinite loop
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The for loop runs from i = 0 to i < 5, incrementing i by 1 each time. The output is the values of i from 0 to 4.
15. | Which of the following is NOT a valid type of inheritance in Java? |
---|
A. Single
B. Multiple
C. Hierarchical
D. Hybrid
View Answer Discuss Work SpaceAnswer: option d
Explanation: