Anda di halaman 1dari 3

Inheritance:

the process of creating a child from the parent class and also define their
properties in the child class.

Types of Inheritance:

1) Single
2) Multiple--- that not present in JAVA
3) Multilevel
4) heirarchical
5) Hybrid---- that not present in java.

Difference Between super and this keyword?

super is used to call the parent class object


in super concept super constructor must be the first statement in a constructor.

this is used to call the current class object.


in this concept this constructor must be first statement in a constructor.

parent class default constructor priority is high as comparison to any constructor.

if we dont create default constructor in parent class then compiler will create the
default constructor internally.

Parameter constructor of parent only invoke when we call from the child class by
using super(paramter).

Super is used so that we can call the functionality of the parent class without
creating any extra memory.

if i used "this" with variables then that variable behave like a instance variable.

Multiple Inheritance is recovered by using inteface.

Interface in java:
Interface is a blueprint of a class.
we cannot create an object of an Interface.

Q) can we have static method in an interface?

Ans No, we cannot have static method in an interface.


Interface must have only public and abstract method.

Q) can we have non final variables in an interface?


Ans interface must have public,static and final variables.

Interface is used to achieve two things:


1) Multiple Inheritance
2) Fully Abstraction

Nested Interface:
Interface inside interface.

Abstraction: the act of showing essential info and hiding the background details.

Q) What id abstract class and abstract method.

Abstract class: the class that having abstract keyword.


we cannot create an object of abstract class
we cannot create a constructor of abstract class

Abstract Method: the method that having abstract keyword.


it doesnot require any implementation.

rules :
if there is abstract method in a class then that class must be abstract
if there is a abstract class then abstract method may or may not be present.

Q) what is marker Interface?

Ans it is an empty interface. that means it does not have any abstract method.

Anda mungkin juga menyukai