Java Programming Multiple Choice Questions - Variable

This section focuses on the "Variables" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements and other competitive examinations.

1. A ________ provides us with named storage that our programs can manipulate.

A. data type
B. constants
C. operators
D. variable

View Answer

2. Each variable in Java has a specific type, which determines the size and layout of the variable's memory.

C. Can be true or false
D. Can not say

View Answer

3. To declare more than one variable of the specified type, we can use a __________ list.

A. colon-separated
B. bracket-separated
C. comma-separated
D. None of the above

View Answer

4. How many kinds of variables in Java?

A. 2
B. 3
C. 4
D. 5

View Answer

5. Local variables are declared in?

A. methods
B. constructors
C. blocks
D. All of the above

View Answer

6. What is true about Instance Variables in java?

A. Instance variables are declared in a class
B. When a space is allocated for an object in the heap, a slot for each instance variable value is created.
C. Instance variables can be declared in class level before or after use
D. All of the above

View Answer

7. Which variables have no default values?

A. Static Variables
B. Instance Variables
C. Local Variable
D. Both A and B

View Answer

8. Static variables can be accessed by calling with the?

A. Object name
B. Class name
C. Function name
D. Can not say

View Answer

9. Which of the following is an Example of variable initialization?

A. int a, b, c;
B. int a = 10, b = 10;
C. int 10 = a;
D. None of the above

View Answer

10. Access modifiers cannot be used for local variables.

A. Yes
B. No
C. Can be yes or no
D. Can not say

View Answer


* You must be logged in to add comment.