Classes and Objects Flashcards

1
Q

A high-level, powerful programming language that
uses the Object-Oriented Programming (OOP)
approach.

A

Java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A programming style that models real-world entities as “objects.”

A

Object-Oriented Programming (OOP)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Objects have: (mention 2)

A

Data (fields): Information or attributes.
Behavior (methods): Actions or functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Objects have:
Data (fields): ______________
Behavior (methods): _____________

A

Data: Information or attributes.
Behavior: Actions or functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Programs are written as step-by-step instructions or
functions.

A

Traditional Programming (Procedural)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Class?

A

A class is like a blueprint or template for creating
objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Mention two Variables in a Class:

A

Instance Variables
Class Variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What type of variable is this in a class?
* Declared inside a class but outside any method.
* Non-static and unique to each object.

A

Instance variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What type of variable is this in a class?
* Declared with the static keyword.
* Shared across all objects of the class.

A

Class variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

An ________ is a real-world entity created from a class.

A

object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If a ______ is a blueprint, an object is the actual
product made from that blueprint.

A

class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The process of creating an object
from a class.

A

Instantiation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

___________ are the characteristics or properties of
an object.

A

Attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Attributes are also called ________ or ________
variables.

A

fields or instance
variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Do attributes belong to a class? True or false

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Each object has its own copy of class
variables. True or false

A

False
Each object has its own copy of instance
variables not class variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

_________ variables are specific to an object
and can only be accessed within that
object.

A

Instance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Java reserves ________ for the object based on the class blueprint.

A

memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

The name of the class.

A

ClassName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

The name of the object (instance).

A

objectName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

This keyword allocates memory for the object.

A

new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Calls the class constructor to initialize the object.

A

ClassName()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

We can create ___________ attributes (which belong to individual objects) and ________ attributes (which belong to the class itself)

A

non-static , static

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

To access the attributes of a class, we create an ________ and use _____________.

A

object , dot notation (.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
A special method used to initialize objects when they are created.
Constructor
26
A constructor is a special method used to _________ objects when they are created.
initialize
27
It has the same name as the class and runs automatically during object instantiation.
Constructor
28
What are the 2 types of Constructors?
1.Default Constructor (No Parameters) 2. Constructor with Parameters
29
Assigns default values to object attributes.
Default Constructor
30
Allows assigning custom values when creating an object.
Constructor with Parameters
31
Default Constructor has list of parameters. True or false?
**False** Default constructor has no parameter.
32
What are the types of access modifiers?
● **Public**: Accessible everywhere. ● **Private**: Accessible within the class only. ● **Protected**: Accessible within the package and subclasses. ● **Default**: Accessible within the package.
33
● __________: Accessible everywhere. ● __________: Accessible within the class only. ● __________: Accessible within the package and subclasses. ● __________: Accessible within the package.
● Public: Accessible everywhere. ● Private: Accessible within the class only. ● Protected: Accessible within the package and subclasses. ● Default: Accessible within the package.
34
Multiple methods with the same name but different parameters.
Method Overloading
35
Wrapping data and methods into a single unit.
Encapsulation
36
One class acquires properties and methods of another class.
Inheritance
37
Refers to parent class members.
super Keyword
38
Ability to take multiple forms.
Polymorphism
39
Two types of Polymorphism:
Compile-time (Method Overloading) Runtime (Method Overriding)
40
* Hiding implementation details and showing functionality. * Achieved through Abstract Classes and Interfaces.
Abstraction
41
* Cannot be instantiated. * Can have abstract and non-abstract methods.
Abstract class
42
* It is a collection of abstract methods. * It also Implements multiple inheritance.
Interface
43
final Keyword: ● _________: Constant value. ● _________: Cannot be overridden. ● _________: Cannot be inherited.
● **Final Variable:** Constant value. ● **Final Method**: Cannot be overridden. ● **Final Class**: Cannot be inherited.
44
Superclass of all classes in Java.
Object Class
45
. Type Casting ● _________: Subclass to Superclass. ● _________: Superclass to Subclass.
● **Upcasting**: Subclass to Superclass. ● **Downcasting**: Superclass to Subclass
46
instanceof Operator: * Checks if an object is an instance of a class. (visualize the syntax to answer)
if (obj instanceof ClassName) {}
47
Group of related classes and interfaces
Packages
48
Used to include packages.
import keyword
49
Accessing Package Members - Fully Qualified Name or ________________.
Import Statement
50
Mechanism to handle runtime errors.
Exception Handling
51
Automatic memory management.
Garbage Collection
52
Convert primitive data types into objects.
Wrapper Classes
53
Immutable sequence of characters.
String Class
54
Collection of similar type elements.
Arrays
55
Resizable array implementation.
Array list Class
56
Stores key-value pairs.
HashMap Class
57
Reading and writing files.
File handling
58
Concurrent execution of two or more threads.
Multithreading
59
Converting an object into byte stream.
Serialization
60
OOP enhances code _________, ____________, ___________.
reusability, security, and modularity
61
Method overloading allows a class to have ___________ with the same ________ but different ____________.
multiple methods, same name but different parameter list
62
Retrieves the value of a private variable.
Accessor (Gate)
63
Modifies the value of a private variable with validation.
Mutator (Setter)
64
Variables or methods can only be accessed within the same class.
Private Access