Skip to main content

Posts

Showing posts from April, 2019

Top 10 java OOPS interview questions

1) What is an object ?  An Object is instance of class. A class defines type of object. Each object belongs to some class.Every object contains state and behavior. State is determined by value of attributes and behavior is called method. Objects are alos called as an instance. Lets consider this class : public class FirstClass { public static void main (String[] args) { FirstClass f = new FirstClass(); System. out . println ( "My First class" ); } } To instantiate the FirstClass we use this statement object Initialize: FirstClass f= new FirstClass(); f is used to refer FirstClass object. 2) How to call one constructor from the other constructor ?  With in the same class if we want to call one constructor from other we use this() method. Based on the number of parameters we pass appropriate this() method is called. Restrictions for using this method :  1) this must be the first statement in the constructor 2)we cannot use two...