A class serves as a blueprint, defining the structure and behavior of objects.
Flip to see [answer/question]
Flip to see [answer/question]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Flip
Revise later
SpaceTo flip
If confident
All Flashcards
What is the role of a class in object creation?
A class serves as a blueprint, defining the structure and behavior of objects.
What does the new keyword do?
It's used to create a new object (instance) of a class, calling the constructor.
Explain the difference between a class and an object.
A class is a blueprint, while an object is a specific instance of that blueprint.
What is the significance of objects being reference types?
Objects store memory locations rather than actual values, affecting how they are handled in memory and during assignment.
What is the purpose of a constructor?
To initialize the state of an object when it is created.
What are the key principles of OOP?
Abstraction, Encapsulation, Inheritance, and Polymorphism.
What is the role of methods in a class?
Methods define the behaviors or actions that an object can perform.
Why is understanding objects important in Java?
Because Java is an object-oriented language, and objects are fundamental building blocks.
What does it mean for an object to be an instance of a class?
It means the object is a specific realization or example created from the class's blueprint.
What happens when you assign one object to another?
You are copying the reference (memory address), not creating a new, independent object.
What are the differences between primitive types and reference types?
Primitive types store values directly; reference types store memory addresses. Primitive types start with lowercase; reference types start with uppercase.
What is the difference between == and .equals() when comparing objects?
== compares memory addresses (references); .equals() compares the content of the objects (if properly implemented).
Compare the use of the String class with the Math class.
String is used to create and manipulate text; Math provides static methods for mathematical operations. String objects are created with new or string literals; Math cannot be instantiated.
What is the difference between a static method and an instance method?
A static method belongs to the class itself and is called using the class name; an instance method belongs to an object of the class and is called using the object's name.
Compare Abstraction and Encapsulation.
Abstraction focuses on hiding complexity and showing only essential features, while encapsulation focuses on bundling data and methods that operate on that data, protecting it from outside access.
Compare Inheritance and Polymorphism.
Inheritance allows a class to inherit properties and behaviors from another class, promoting code reuse, while polymorphism allows objects of different classes to be treated as objects of a common type, enabling flexibility and extensibility.
What is the definition of Object-Oriented Programming (OOP)?
A programming paradigm based on the concept of 'objects', which contain data in the form of fields (attributes) and code in the form of procedures (methods).
What is the definition of a Class?
A blueprint or template for creating objects. It defines the characteristics and behaviors that objects of that class will have.
What is the definition of an Object?
A specific instance of a class. It's a concrete entity created from a class blueprint.
What is the definition of a Constructor?
A special method used to create and initialize objects of a class.
What is the definition of a Method?
A function associated with an object, defining its behavior.
What is the definition of a Reference Type?
A data type that stores the memory address of an object, rather than the object's actual value.
What is the definition of Abstraction?
Showing only essential attributes and hiding unnecessary information.
What is the definition of Encapsulation?
Bundling of data and methods that operate on that data within a class, and restricting direct access to some of the object's components.
What is the definition of Inheritance?
A mechanism where a new class inherits properties and behaviors from an existing class.