Recall & Review
beginner
What is an object in Java?
An object is a real-world entity that has state (attributes) and behavior (methods). It is an instance of a class.
Click to reveal answer
beginner
How do you create an object in Java?
You create an object by using the <code>new</code> keyword followed by the class constructor, for example: <code>ClassName obj = new ClassName();</code>Click to reveal answer
intermediate
What does the
new keyword do in Java?The
new keyword allocates memory for the new object on the heap and calls the constructor to initialize it.Click to reveal answer
beginner
What is a constructor in Java?
A constructor is a special method used to initialize new objects. It has the same name as the class and no return type.Click to reveal answer
beginner
Can you create multiple objects from the same class?
Yes, you can create many objects from the same class, each with its own separate state.
Click to reveal answer
Which keyword is used to create an object in Java?
✗ Incorrect
The
new keyword is used to create new objects in Java.What does a constructor do in Java?
✗ Incorrect
A constructor initializes a new object when it is created.
What is the correct way to create an object of class
Car?✗ Incorrect
The correct syntax uses
new followed by the constructor: Car c = new Car();Where is the memory allocated when you create a new object in Java?
✗ Incorrect
Objects are stored in the heap memory in Java.
Can you create two objects from the same class?
✗ Incorrect
You can create as many objects as you want from the same class.
Explain how to create an object in Java and what happens behind the scenes.
Think about the steps from writing code to having a usable object.
You got /4 concepts.
Describe the role of a constructor in object creation.
Focus on what makes constructors special compared to other methods.
You got /4 concepts.