
The following things are very much mandatory for calling any method. 25.Can we override static, final, private methods?Īnswer: No 26.What are required things to call methods? Yes, we can write multiple default methods and class methods also (abstract format only).

19.What is factory method?Īnswer: A method which is returns either same class memory other class memory is called factory method. 18.What the difference between void and non-void method?Īnswer: The method which is unable to carry information from called area to calling area is called void method the method which is able to carry the information from called area to calling area is called non-void method.

17.Can we write return statement without value in void method?Īnswer: Yes.

If we are unable to create object for a class, but still if we want to execute some logic and if we are not giving to subclasses to change our logic then we should prefer static methods. No, we are unable to use, the reason are by default non-static final reference variables. 15.Can we this and super keywords in static context? To make our logic/functionalities to common for all we should use non-static block, whereas constructor is useful for providing different functionalities for different object. 14.What is the difference between constructor and non-static block? To make our logic/functionalities to common for all objects, mean while of object creation then we should use non-static block. 12.What is singleton?Ī class which is allows to programmer to create only one object. Super () method is useful for making communication between one constructor to another constructor between super and sub classes. This () method is useful for making communication between one constructor to another constructor within the same class.
#AMEERPET JAVA NOTES UPDATE#
Update Your Skills form Our Experts: Core Java Online Training 10.What is use of this () in java? If we want perform different operations in different object creations mode then we should prefer constructor overloading. 9.Why should we go for constructor overloading?

Mean while of creating object, if we want to copy the data from existed object to new creating object within the different memory location then we should use copy constructor. Initializer is useful for replacing default values with original values of static variables in static initialization phase. Preparer is useful for providing default values for static variables in static loading phase. 5.What is the use of constructor?Ĭonstructor is useful for initialize the non-static variables meanwhile of object creation. Once we initialize the final variable, we can’t reinitialize the variable again either with same value or different value. New keyword is useful for providing memory for non-static data, it is individual, where as static keyword is useful for providing memory static data by default by JVM, it is common for all. } 3.What is the difference between static and new keyword? Can we write return statement without value in constructors? Can we write static block within the method?Ĭompiletime Error: Illegal start of expression.
