Recall & Review
beginner
What is a class in Java?A class in Java is a blueprint or template that defines the structure and behavior (data and methods) of objects. It groups related variables and functions together.Click to reveal answer
beginner
How do you define a simple class named <code>Car</code> in Java?You define it using the <code>class</code> keyword followed by the class name and curly braces:<br><pre>public class Car {
// fields and methods
}</pre>Click to reveal answer
beginner
What are fields and methods inside a class?
Fields are variables that hold data about the object. Methods are functions that define actions or behaviors the object can perform.
Click to reveal answer
beginner
What does the keyword <code>public</code> mean when used before a class or method?<code>public</code> means the class or method can be accessed from other classes anywhere in the program.Click to reveal answer
beginner
Why do we use classes in programming?
Classes help organize code by grouping related data and actions. They make code reusable, easier to understand, and model real-world things.
Click to reveal answer
Which keyword is used to define a class in Java?
✗ Incorrect
The keyword
class is used to define a class in Java.What is inside a class in Java?
✗ Incorrect
A class contains fields (variables) and methods (functions) that define data and behavior.
What does
public before a class mean?✗ Incorrect
public means the class can be accessed from any other class.Which of these is a valid class name in Java?
✗ Incorrect
Class names must start with a letter or underscore and cannot be Java keywords.
Car123 is valid.Why do programmers use classes?
✗ Incorrect
Classes organize related data and actions, making code easier to manage and reuse.
Explain what a class is and why it is useful in Java programming.
Think about how a class models real-world things.
You got /4 concepts.
Describe the parts inside a class and their roles.
What does a class hold to represent an object?
You got /4 concepts.