Java MCQ – Multiple Choice Questions and Answers – OOPs
This collection of Java Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer focuses on “Java OOPs”.
1. Which of the following is not relevant to OOPS?
A Object and Class
B Encapsulation and Inheritance
C Enumerated type and Structure
D Constructor and Method
2. Can we overload constructor in derived class?
A Yes
B No
3. Which is an abstract data type?
A Double
B String
C Enum
D Class
4. Which keyword is used to inherit a class in Java?
A inherit
B implement
C extend
D extends
5. A private member of a class is accessible to ________________.
A only members of the same class
B members to the same package
C in subclass
D everywhere
6. In OOPs in Java, private, public & protected are ________________.
A Interfaces
B Classes
C Method signature
D Access Modifiers
7. Which doesn’t have a body?
A Class
B Abstract Method
C Method
D Interface
8. We can’t create an instance of ___________.
A Nested class
B Parent class
C Abstract class
D Anonymous class
9. Constructor can return a value ___________.
A True
B False
10. OOPs is invented by _____________.
A James Gosling
B Rasmus Lerdorf
C Alan Kay
D Tim Berners-Lee
11. Which Feature of OOP boost the code reusability?
A Encapsulation
B Polymorphism
C Inheritance
D Abstraction
12. Which of the following syntax used to create an object of Class in Java?
A Classname obj = new() Classname()
B Classname obj = new Classname;
C Classname obj = new Classname();
D None of the above
13. Which is used to create an Abstract class?
A Creating at least one member function as a pure virtual function
B Creating at least one member function as a virtual function
C Declaring as Abstract class using virtual keyword
D Declaring as Abstract class using static keyword
14. What is the output of the following Java code?
class Person
{
private int age;
private Person()
{
age = 24;
}
}
public class Test
{
public static void main(String[] args)
{
Person p = new Person();
System.out.println(p.age);
}
}
A 24
B Compilation error
C Runtime error
D None of the above
15. Which of the following is common class for exception handling?
A Try
B Object
C Exceptions
D Errors
16. What is the output of the following Java code?
class A
{
int data = 5;
A() {
data = 10;
}
}
public class Test
{
public static void main(String args[])
{
A obj = new A();
System.out.println(obj.data);
}
}
A 5
B 10
C Compilation error
D Runtime error
17. Is there any compiler error?
class Point
{
int x, y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
public static void main(String args[])
{
Point obj = new Point();
}
}
A True
B False


