menu

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

Discuss Work Space

Answer: option d

Explanation:

String is not a control statement in JavIt is a class that is used to represent a sequence of characters.

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

Discuss Work Space

Answer: 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

Discuss Work Space

Answer: option d

Explanation:

Static is not an access modifier in JavIt is used to define a class-level variable or method.

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

Discuss Work Space

Answer: 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

Discuss Work Space

Answer: option d

Explanation:

Hybrid inheritance is not supported in JavIt is a combination of multiple and hierarchical inheritance.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now