Recall & Review
beginner
What is a class in Java?A class is a blueprint or template that defines the structure and behavior (fields and methods) that objects created from the class will have.Click to reveal answer
beginner
What is an object in Java?
An object is an instance of a class. It represents a real-world entity with state (data) and behavior (methods) defined by its class.
Click to reveal answer
beginner
How do you create an object from a class in Java?You use the 'new' keyword followed by the class constructor. For example: <br> <code>ClassName obj = new ClassName();</code>Click to reveal answer
intermediate
What is the purpose of a constructor in a class?
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
Explain the difference between fields and methods in a class.
Fields are variables that hold data about the object. Methods are functions that define the behavior or actions the object can perform.
Click to reveal answer
Which keyword is used to create an object in Java?
✗ Incorrect
The 'new' keyword is used to create a new object instance from a class.
What does a constructor do in a Java class?
✗ Incorrect
Constructors initialize new objects when they are created.
Which of the following is NOT a part of a class?
✗ Incorrect
Objects are instances created from classes, not part of the class itself.
How do you call a method named 'run' on an object 'car'?
✗ Incorrect
You call a method on an object using dot notation: objectName.methodName();
What is the correct way to declare a class named 'Dog'?
✗ Incorrect
The correct syntax is: class ClassName {}
Describe what a class and an object are in Java and how they relate to each other.
Think about how a cookie cutter (class) relates to cookies (objects).
You got /3 concepts.
Explain the role of constructors in creating objects and how they differ from regular methods.
Constructors prepare new objects when they are born.
You got /4 concepts.