Oops concept Flashcards

1
Q

Inheritance

A

When one object acquires all the properties and behaviors of a parent object, it is
known as inheritance. It provides code reusability. It is used to achieve runtime
polymorphism.

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

Encapsulation

A

Binding (or wrapping) code and data together into a single unit are known as
encapsulation. For example, a capsule, it is wrapped with different medicines.
A java class is the example of encapsulation. Java bean is the fully encapsulated
class because all the data members are private here.

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

Abstraction

A

Hiding internal details and showing functionality is known as abstraction. For
For example, we don’t know the internal processing of the phone
In Java, we use abstract class and interface to achieve abstraction.

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

Polymorphism

A

If one task is performed in different ways, it is known as polymorphism. For
example: to convince the customer differently, to draw something.

we use method overloading and method overriding to achieve
polymorphism.

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

Class

A

The collection of objects is called class. It is a logical entity.
Class is a blueprint of method

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

Object

A

Any entity that has state and behaviour is known as an object. For
For example, a chair, pen, table, keyboard, bike, etc. It can be physical or
logical.

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

Constructor

A

A constructor is a special method used to initialize objects when they are created.
It has the same name as the class and doesn’t have a return type.
Constructors are called automatically when an object is instantiated using the new keyword.

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

Instance Variable

A

Variables declared in a class but outside any method. They belong to instances of the class and each object gets its own copy.

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

Local variables

A

Variables declared within a method or a block. They exist only within that method or block and are not accessible outside.

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

Static variable

A

Also known as class variables, these are declared with the static keyword. They are shared among all instances of a class and exist independently of any particular instance.

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

This

A

Refers to the current instance of the class. Used to differentiate instance variables from local variables when they have the same name.

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

Static

A

Denotes a variable or method that belongs to the class rather than an instance. It is shared among all instances of the class.

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

New

A

Used to create an instance of a class. Allocates memory and initializes the object.

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

Super

A

Refers to the superclass or parent class. Used to invoke methods or access fields from the superclass.

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

Final

A

Indicates that a variable, method, or class cannot be changed or extended. For variables, it means a constant value.

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

Continue

A

Skips the rest of the loop’s body and moves to the next iteration.

17
Q

Break

A

exit the loop

18
Q

Method overloading

A

Methods having the same name but different in
parameters, it is known as Method Overloading.

19
Q

Method overriding

A

If subclass (child class) has the same method as declared in the parent class,
it is known as method overriding in Java

20
Q

Compile time polymorphism

A

It occurs during the compilation phase.
Decision made at compile time

21
Q

Run time polymorphism

A

Method overriding.
It occurs during the execution of a program.
Decision made at runtime

22
Q

Composition

A

The composition is a way to design or implement the has-a relationship. The has-a relationship is used to implement an instance variable that refers to another object

23
Q

Synchronisation

A

Synchronization in Java is a technique used to control the access and execution of multiple
threads to ensure that only one thread can access a shared resource or code block at a time.

24
Q

Coupling

A

separation of concerns is known as coupling. It means that an object cannot change or modify the state or behavior of other objects directly.

25
Q

Threads

A

A thread in Java is a smaller unit of a process that can run concurrently with other threads within the same process.