GRADED A+
What is a `class` in Java?
✔✔ A class in Java is a blueprint for creating objects. It defines the properties (attributes) and
behaviors (methods) that the objects of that class will have.
Explain the difference between a `primitive data type` and a `reference data type`.
✔✔ A primitive data type holds simple values like integers, characters, and booleans. A
reference data type holds references to objects, such as arrays or instances of classes.
What is a `constructor` in Java?
✔✔ A constructor is a special method in a class that is called when an object of that class is
created. It is used to initialize the object's attributes.
What does the keyword `new` do in Java?
1
, ✔✔ The `new` keyword creates a new instance (object) of a class and allocates memory for it.
What is the difference between `instance variables` and `local variables`?
✔✔ Instance variables are declared in a class and are accessible by all methods in that class.
Local variables are declared inside a method and are only accessible within that method.
Explain what `method overloading` is in Java.
✔✔ Method overloading occurs when two or more methods in a class have the same name but
different parameters (different number or type of arguments).
What is the purpose of the `main()` method in a Java program?
✔✔ The `main()` method is the entry point of any Java program. It is where the program starts
execution.
What is the difference between `public` and `private` access modifiers?
2