CodeStudy.net
Toggle Menu
Home
Online Java Compiler
Tutorials
Java Tutorial
Python Tutorial
SQL Database Design
Blog
All Posts
Object-Oriented Programming in Java
Assess your grasp of classes,inheritance,and polymorphism.
1. What is the blueprint for creating objects in Java?
Class
Object
Method
Interface
2. Which of the following are core Object-Oriented Programming principles in Java?
Encapsulation
Inheritance
Polymorphism
Abstraction
Procedural Programming
3. A Java class can extend multiple classes.
True
False
4. What keyword is used to inherit a class in Java?
5. Which access modifier restricts member access to within its own class only?
public
private
protected
default
6. What is the term for multiple methods with the same name but different parameters in a class?
Overriding
Inheritance
Overloading
Polymorphism
7. Which of the following are primitive data types in Java?
int
String
boolean
char
Object
8. An abstract class can contain non-abstract (concrete) methods.
True
False
9. What is the superclass of all classes in Java?
Class
Object
Super
Parent
10. What OOP principle refers to wrapping data and methods into a single unit?
11. Which keyword refers to the current instance of a class?
this
super
self
current
12. Which statements about Java constructors are true?
A constructor has the same name as the class
A constructor can return a value
A class can have multiple constructors (overloading)
A constructor must be declared public
13. A Java interface can contain static methods.
True
False
14. What is required for a method to override a superclass method?
Same name and return type
Same name, parameters, and return type
Same name and access modifier
Same parameters and access modifier
15. What keyword is used to prevent a class from being inherited?
16. Which of the following enable polymorphism in Java?
Method overloading
Method overriding
Interface implementation
Static method calls
17. Which keyword is used to call a superclass constructor?
super()
this()
parent()
base()
18. What is an instance variable?
A variable declared inside a method
A variable declared in a class, outside methods
A variable marked with 'static'
A variable with 'final' modifier
19. What term describes an object's ability to take multiple forms?
20. Which of the following declares a constant in Java?
const int MAX = 100;
final int MAX = 100;
static int MAX = 100;
constant int MAX = 100;
Reset
Answered 0 of 0 — 0 correct