Variables in Java are containers used to store data values. Every variable in Java has a type, a name, and a scope. Java supports different types of variables such as local, instance, and static variables, each with specific usage and lifetime.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which keyword is used to declare a variable in Java?
Correct
Incorrect
Question 2 of 15
2. Question
What is the default value of an int instance variable in Java?
Correct
Incorrect
Question 3 of 15
3. Question
What is the scope of a local variable in Java?
Correct
Incorrect
Question 4 of 15
4. Question
Which of these can not be used in a variable name?
Correct
Incorrect
Question 5 of 15
5. Question
Which variable is shared by all instances of a class?
Correct
Incorrect
Question 6 of 15
6. Question
What happens if you try to use an uninitialized local variable?
Correct
Incorrect
Question 7 of 15
7. Question
Which of the following is a valid variable declaration in Java?
Correct
Incorrect
Question 8 of 15
8. Question
What will be the output of the following?
int a = 10; System.out.println(a);
Correct
Incorrect
Question 9 of 15
9. Question
. Which type of variable must be declared static inside a class to access it without creating an object?
Correct
Incorrect
Question 10 of 15
10. Question
What is the correct syntax to declare a constant variable in Java?
Correct
Incorrect
Question 11 of 15
11. Question
Which variable has the longest lifetime?
Correct
Incorrect
Question 12 of 15
12. Question
Which of the following variables is created when a method is called and destroyed when the method exits?
Correct
Incorrect
Question 13 of 15
13. Question
Which of the following best describes instance variables?
Correct
Incorrect
Question 14 of 15
14. Question
What is the output of the following code?
public class Test { static int x = 5; public static void main(String[] args) { x = x + 10; System.out.println(x); } }
Correct
Incorrect
Question 15 of 15
15. Question
What happens if you declare two variables with the same name in the same scope?
Correct
Incorrect
Summary
These multiple choice questions on Java Variables cover types, scope, access, declaration, and best practices. Ideal for Java beginners, interview preparation, and coding assessments.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.