• No results found

What is Abstraction ?

In document Hibernate Interview Question (Page 52-55)

49 fileOutStream.flush();

6. What is Abstraction ?

Showing the essential and hiding the non-Essential is known as Abstraction. 7.What is 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 interface of the object.

8.What is mean by Inheritance?

Inheritance is the Process by which the Obj of one class acquires the properties of Objsanother 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.

Adv: Reusability of code , accessibility of variables and methods of the Base class by the Derived class. 9.What is Polymorphism?

The ability to take more that one form, it supports Method Overloading & Method Overriding. 10.What is 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 timePolymorphism.

When a method in a class having the same method name with different arguments (diff Parameters o 12.What is Method Overriding?

When a method in a sub Class having same method name with same arguments present in a super class it is said to be Method overriding. This is Run time Polymorphism.

Dynamic dispatch 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.

14.What is mean by 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).

15.What is mean by Bite code?

Is a optimized set of instructions designed to be executed by Java-run time system, which is called the Java Virtual machine (JVM), i.e. in its standard form, the JVM is an Interpreter for byte code.

16.What is class variable?

A data item associated with a particular class as a whole–not with particular instances of the class. Class variables are defined in class definitions. Also called a static field.

17.What is instance variable?

Any item of data that is associated with a particular object. Each instance of a class has its own copy of the instance variables defined in the class. Also called a field

18.What is local variable?

A data item known within a block, but inaccessible to code outside the block. For example, any variable defined within a method is a local variable and can’t be used outside the method.

19.What is class method ?

A method that is invoked without reference to a particular object. Class methods affect the class as a whole, not a particular instance of the class. Also called a static method.

20.What is instance method ?

Any method that is invoked with respect to an instance of a class. Also called simply a method. 21.Define Interface&Rules?

Interfaces can be used to implement the Inheritance relationship between the non-related classes that do not belongs to the same hierarchy, i.e. any Class and anywhere in hierarchy. Using Interface, you can specify what a class must do but not how it does.

Rules for defining a 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.

 If the Implementation for all the methods declared in the Interface are not provided , the class itself has to declare abstract, other wise the Class will not compile.

 If a class Implements two interface and both the Intfs have identical method declaration, it is totally valid.  If a class implements tow interfaces both have identical method name and argument list, but different return

types, the code will not compile.

 An Interface cant be instantiated. Intf Are designed to support dynamic method resolution at run time.  An interface can not be native, static, synchronize, final, protected or private.

 The Interface fields can not be Private or Protected.

 A Transient variables and Volatile variables can not be members of Interface.

 The extends keyword should not used after the Implements keyword, the Extends must always come before the Implements keyword.

 A top level Interface can not be declared as static or final.

 If an Interface species an exception list for a method, then the class implementing the interface need not declare the method with the exception list.

 If an Interface can not specify an exception list for a method, the class can not throw an exception.  If an Interface does not specify the exception list for a method, he class can not throw any exception list.

21.What is mean 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.

If a Class is declared as abstract , no instance of that class can be created.

If a method is declared as abstract, the sub class gives the implementation of that class.

Even if a single method is declared as abstract in a Class , the class itself can be declared as abstract. In abstract Class the keyword abstract must be used for method.

Abstract class cannot be marked as final

22.Difference Between Interfaces And Abstract class ?

All the methods declared in the Interface are Abstract, where as abstract class have both abstract method and concrete.

In abstract class keyword abstract must be used for method, where as in Interface we need not use the keyword for methods(interface methods are by default abstract).

Interface can have only abstract method and constants

Interface does not have constructor where as abstract class have constructor. 23.What are access specifiers and access modifiers ?

Public

: The Variables and methods can be access any where and any package. Protected

: The Variables and methods can be access same Class, same Package & sub class. Protected keyword is used when we have different packages

Private

: The variable and methods can be access in same class only. 24. What are Identifiers ?

Identifiers are the Variables that are declared under particular Datatype. 25. What are Literals?

Literals are the values assigned to the Identifiers.

In document Hibernate Interview Question (Page 52-55)

Related documents