Type Here to Get Search Results !

Java quiz - Variables & Data types

Question 1:

What is the correct syntax to declare an integer variable named "num" in Java?

Answer: a) int num;

Question 2:

Which of the following is a valid identifier for a variable in Java?

Answer: b) _variable

Question 3:

Which of the following is NOT a primitive data type in Java?

Answer: c) string

Question 4:

What is the default value of an integer variable in Java if it is not initialized?

Answer: a) 0

Question 5:

Which of the following data types is used to store characters in Java?

Answer: a) char

Question 6:

What is the maximum value that can be stored in an integer variable of type "short" in Java?

Answer: c) 32767

Question 7:

Which of the following is NOT a valid variable name in Java?

Answer: b) 123Variable

Question 8:

Which of the following data types is used to store floating-point numbers with single precision in Java?

Answer: a) float

Question 9:

What is the correct way to declare a constant variable in Java?

Answer: a) final int num = 10;

Question 10:

Which of the following data types is used to store true or false values in Java?

Answer: b) boolean

Post a Comment

0 Comments