Home
MCQs
Java MCQs
Variables
Java MCQs

Java MCQs - Variables

Variable is the name of reserved location in memory which is used in programming language. In this list of mcqs you will cover all possible mcqs for Java variables

1. Where to declare local variables ?

A. It declares inside the class and outside of method.

B. It declares inside the class with static prefix and outside of method.

C. It declares inside the method.

Answer: C

2. Where to declare instance variables ?

A. It declares inside the class and outside of method.

B. It declares inside the class with static prefix and outside of method.

C. It declares inside the method.

Answer: A

3. Where to declare class variables ?

A. It declares inside the class and outside of method.

B. It declares inside the class with static prefix and outside of method.

C. It declares inside the method.

Answer: B

4. Which of following can not be used as variable name in Java programming language ?

A. literal

B. Keywords

C. Identifier

D. Identifier and Keywords

Answer: B

5. A name of variable is known as

A. Data Type

B. Constant

C. Identifier

Answer: C

6. Which is the invalid variable name ?

A. tenthTeam

B. TenthTeam

C. 10thTeam

D. None of Above

Answer: C

7. A variable name should not begin with

A. A number

B. Special characters but underscore and dollar sign

C. All of above

Answer: C

8. Which is the valid variable name ?

A. 5thTeam

B. &5thteam

C. _5thTeam

D. None of Above

Answer: C

9. Which are the invalid variable names ?

A. 1stLevel

B. first Level

C. *firstLevel

D. All of Above

Answer: D

10. Which are the valid variable names ?

A. $1stLevel

B. _1stLevel

C. £1stLevel

D. All of Above

Answer: D