Loading

Q1.

Which of the following is a correct way to declare a variable in Java?

A. int num = 10;

B. int = num 10;

C. num int = 10;

D. integer num = 10;

Q2.

What is the default value of an instance variable of type boolean in Java?

A. true

B. false
C. null
D. 0

Q3.

Which of the following variables can be shared among all objects of a class?

A. Local variable

B. Instance variable

C. Static variable

D. Parameter variable

Q4.

Where is a local variable stored in memory?

A. Heap

B. Stack

C. Static area

D. Constant pool

Q5.

Which statement about variable scope in Java is TRUE?

A. Instance variables can be accessed inside static methods directly.

B. Local variables can be used outside the method they are declared in.

C. Static variables are accessible using the class name.

D. Local variables get default values automatically.