Java is an object-oriented programming language, and the concepts of classes and objects are at its core. A class is a blueprint or template that defines the structure and behavior (data and methods) of objects. An object is an instance of a class — a real-world entity you can work with in code.
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 create an object in Java?
Correct
Incorrect
Question 3 of 15
3. Question
What is the output of the following code?
class Box { int width = 5; }
public class Test { public static void main(String[] args) { Box b = new Box(); System.out.println(b.width); } }
Correct
Incorrect
Question 4 of 15
4. Question
What is an object in Java?
Correct
Incorrect
Question 5 of 15
5. Question
Which method is called automatically when an object is created?
Correct
Incorrect
Question 6 of 15
6. Question
Can a class contain multiple methods with the same name?
Correct
Incorrect
Question 7 of 15
7. Question
What is the correct way to declare a class named `Book`?
Correct
Incorrect
Question 8 of 15
8. Question
Which statement is true about constructors in Java?
Correct
Incorrect
Question 9 of 15
9. Question
What will happen if you don’t write a constructor in your class?
Correct
Incorrect
Question 10 of 15
10. Question
What is the output?
class Pen { String color; }
public class Main { public static void main(String[] args) { Pen p1 = new Pen(); p1.color = “Blue”; System.out.println(p1.color); } }
Correct
Incorrect
Question 11 of 15
11. Question
How do you call a method from an object?
Correct
Incorrect
Question 12 of 15
12. Question
Which keyword refers to the current object inside a class method?
Correct
Incorrect
Question 13 of 15
13. Question
Can a class have multiple objects?
Correct
Incorrect
Question 14 of 15
14. Question
What happens when you assign one object to another?
A obj1 = new A(); A obj2 = obj1;
Correct
Incorrect
Question 15 of 15
15. Question
Which of the following can be members of a class?
Correct
Incorrect
Summary
This MCQ set helps reinforce your understanding of Java class definitions, object creation, constructors, method calling, `this` keyword, and object reference handling. Ideal for interviews, beginner practice, and course quizzes.
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.