Java VAC QUESTIONS
Java VAC QUESTIONS
Java VAC QUESTIONS
1
6. Which of the following is a primitive data type in Java?
A) String
B) Boolean
C) Array
D) Class
13. Which of the following is used to allocate memory for an object in Java?
A) malloc
B) alloc
C) new
D) create
17. What does the 'final' keyword mean when applied to a variable?
A) The value of the variable can change
B) The value of the variable cannot be changed
C) The variable can be inherited
D) The variable is a global variable
3
19. What does the 'static' keyword mean in Java?
A) The variable or method is specific to an instance
B) The variable or method belongs to the class, not an instance
C) The variable or method can be changed at runtime
D) The variable or method is only accessible within the class
23. Which OOP principle focuses on restricting access to certain details of an object?
A) Inheritance
B) Polymorphism
C) Abstraction
D) Encapsulation
4
25. What is inheritance in Java?
A) Acquiring features of a class
B) Hiding details of implementation
C) Writing multiple methods with the same name
D) Creating objects from a class
30. Which of the following can be used for dynamic method dispatch in Java?
A) Constructor
B) Abstract class
C) Interface
D) Both B and C
5
31. What is meant by method overriding?
A) Two methods with the same name but different parameters
B) A method in a subclass having the same signature as in its superclass
C) Declaring multiple methods with the same name
D) Changing the return type of a method in a subclass
32. What happens when a subclass defines a static method with the same
signature as a static method in its superclass?
A) Compile-time error
B) The superclass method is hidden
C) The superclass method is overridden
D) The subclass method is called at runtime
6
D) Calling multiple constructors at the same time
38. Which of the following statements is true about the Object class in Java?
A) It is the parent class of all classes in Java
B) It is the child class of every class in Java
C) It must be extended by every class in Java
D) It cannot be inherited
39. In which of the following situations would you use super() in Java?
A) To invoke a constructor of the superclass
B) To invoke a method of the superclass
C) To override a superclass method
D) To call a static method
7
43. Which of the following concepts restricts access to an object's components?
A) Polymorphism
B) Abstraction
C) Encapsulation
D) Inheritance
45. What is the term for when multiple methods share the same name but
have different parameters?
A) Method overriding
B) Method overloading
C) Inheritance
D) Encapsulation
8
49. Which of the following access modifiers allows the most restricted access?
A) public
B) private
C) protected
D) Package-private