1)What is abstraction?
Showing the essential and hiding the nonEssential is known as Abstraction.
2)Define Encapsulation?
The Wrapping up of data and functions into a single unit is known as Encapsulation. Encapsulation is the term given to the process of hiding the implementation details of the object. Once an object is encapsulated, its implementation details are not immediately accessible any more. Instead they are packaged and are only indirectly accessed via the reference of the object.
3)Define Inheritance?
It is the Process by which the Obj of one class acquires the properties of Obj’s another Class. Inheritance is the method of creating the new class based on already existing class, the new class derived is called Sub class which has all the features of existing class and its own, i.e sub class.
Advantage of the inheritance:
*Reusability of code
*accessibility of variables and methods of the Base class by the Derived class.
4)Define Polymorphism?
The ability to take more that one form, it supports Method Overloading & Method Overriding.
5)Define Method overloading?
When a method in a class having the same method name with different arguments (diff Parameters or Signatures) is said to be Method Overloading. This is Compile time Polymorphism. Using one identifier to refer to multiple items in the same scope.
6) Define Method Overriding?
When a method in a Class having same method name with same arguments is said to be Method overriding. This is Run time Polymorphism. Providing a different implementation of a method in a subclass of the class that originally defined the method.
7)Difference between overloading and overriding?
1. In Over loading there is a relationship between the methods available in the same class, where as in Over riding there is relationship between the Super class method and Sub class method.
2. Overloading does not block the Inheritance from the Super class , Where as in Overriding blocks Inheritance from the Super Class.
3. In Overloading separate methods share the same name, where as in Overriding Sub class method replaces the Super Class.
4. Overloading must have different method Signatures , Signatures.
8)What is Dynamic dispatch?
It is a mechanism by which a call to Overridden function is resolved at runtime rather than at Compile time , and this is how Java implements Run time Polymorphism.
9)What is a Dynamic Binding?
Dynamic Binding Means the code associated with the given procedure call is not known until the time of call the call at run time. (it is associated with Inheritance & Polymorphism).
10)What is interface?
*A class can implement more than one Interface.
* An Interface can extend one or more interfaces, by using the keyword extends.
*All the data members in the interface are public, static and Final by default.
*An Interface method can have only Public, default and Abstract modifiers.
*An Interface is loaded in memory only when it is needed for the first time.
* A Class, which implements an Interface, needs to provide the implementation of all the methods in that Interface.
11)what is a Marker Interfaces?
A method which has a no name is Marker Interface.
Serializable, Clonable, Remote, EventListener.12)Define Abstract Class?
Abstract classes can be used to implement the inheritance relationship between the classes that belongs same hierarchy.
*Classes and methods can be declared as abstract.
* Abstract class can extend only one Class.
13)Difference Between Interfaces And Abstract class?
o All the methods declared in the Interface are Abstract, where as abstract class must have atleast one abstract method and others may be concrete.
o In abstract class keyword abstract must be used for method, where as in Interface we need not use the keyword for methods.
o Abstract class must have Sub class, where as Interface can’t have sub classes.
o In abstract class keyword abstract must be used for method, where as in Interface we need not use the keyword for methods.
o Abstract class must have Sub class, where as Interface can’t have sub classes.
14)Define Final variable?
All the Variables, methods and classes can be declared as Final. Classes declared as final class can’t be sub classed. Method ‘s declared as final can’t be over ridden. If a Variable is declared as final, the value contained in the Variable can’t be changed. Static final variable must be assigned in to a value in static initialized block.
15)What is Transient Keyword?
Transient can be applied only to class level variables. Local variables can’t be declared as transient. During serialization, Object’s transient variables are not serialized.
No comments:
Post a Comment