Intermidiate Java Concepts Flashcards

1
Q

What is a contructor?

A

It is a special method that is called when an object of a class is created, it is used to initialize an object of a class.

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

What are the types of constturctors?

A
  1. Default constructror
  2. No parameter constructor
  3. Parameterized constructor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a default constructor?

A

It is no parameter constructor that is automaticaly provided by the compiler, if not consturctor is defined by the programmer.

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

what are the possible access modifiers in java and what are thier meanings

A
  1. Private: accesible only withing the same class
  2. Public: Accesible from any class
  3. Protected: Accessible within the same package or sub classes
  4. default: Accessible within the same package
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is polymorphism?

A

Polymorphism means many forms, it allows a single function to behave differently based on different contexts or the object calling it

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

What are the types of polymorphism?

A
  1. Compile Time Polymorphism (mehtod overloading): thesame method name, different type or number of parameters
  2. Run time polymorphism (method overriding): When a subclasss provides a specific implementation of a metod alread define in its parent or supper class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an abstact class?

A

It is a class that objects cannot be created from it may contain abstact methods and concreate methods

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

What is an abstract method?

A

It is a method with no body or implementation

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