Q) Difference Interface
& Abstract Class?
1.
Abstract classes may have some executable methods and methods left unimplemented.
Interface contains no implementation code.
2.
An abstract class can have nonabstract methods. All methods of an
Interface are abstract.
3.
An abstract class can have instance variables. An Interface cannot.
4.
An abstract class can define constructor. An Interface cannot.
5.
An abstract class can have any visibility: public, private, protected.
An Interface visibility must be public (or) none.
Q)
In how many ways can you
create on object in java?
A) Ways
of creating on object:
1) Using new operator
Employee obj=new Employee( );
2) using factory method
NumberFormat obj=new
NumberFormat.getInstance( );
3) using newInstance( ) method
Class c=Class.forName(“Employee”);
For name method will store employee
that class name in an object
This is represented by c.
4) Using cloning( )
Cloning means creating bitwise
exact copy of an existing object.