Oops-Interview Quetion
Oops-Interview Quetion
What is Abstraction?
What is Encapsulation?
Abstraction Encapsulation
Hiding internal implementation and sharing Wrapping of data member and methods.
set of services.
What is Inheritance?
What is Polymorphism?
Method with same name, signature but Method with same name and different return
different return types can’t be created in type can be created.
parent-child class.
Overloading Overriding
type.
We can overload method and constructor We can override method but we can’t
We can overload static, private and final We can’t override static, private and final
method. method.
E.g. “println” method of Printstream E.g. ‘equals’ method of object class and
What is Static?
Static is keyword.
We can apply static keyword with variables, methods, blocks and classes.
The static variable gets memory only once in the class area at the time of class loading. It can
be used to refer to the common properties of all objects, for example, the company name of
employees, college name of students, etc.
A static method belongs to the class rather than the object of a class. It can be invoked without
the need for creating an instance of a class. It can access static data member and can change
the value of it. It can be used to setup database connection.
Static block is used to initialize the static data member. It is executed before the main method
at the time of class loading.
A constructor in Java is a special method that is called when an object of a class is created.
It is used to initialise object as well as non-static variables.
Constructors can also take parameters to initialize data members.
What is Object?