ExamVeda
Login
Home
Data Types and Variables
?

Which of the following is the correct way to declare a boolean variable named isJavaFun and initialize it to true in Java?

Answer & Solution
Correct Answer: Option A
The correct answer is Option A: boolean isJavaFun = true.

In Java, the correct way to declare a boolean variable named isJavaFun and initialize it to true is by using Option A.

Here's the breakdown:

Option A: boolean isJavaFun = true - This is the correct way to declare a boolean variable named isJavaFun and initialize it to true in Java.

Option B: bool isJavaFun = true - This is not the correct syntax in Java. The correct keyword for declaring a boolean variable is boolean, not bool.

Option C: boolean = true - This is not a valid way to declare a boolean variable in Java. It lacks the variable name.

Option D: bool = true - This is also not a valid way to declare a boolean variable in Java. It lacks the variable name, and the keyword bool is not used in Java.

So, the correct way to declare a boolean variable named isJavaFun and initialize it to true in Java is boolean isJavaFun = true.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.