Declaring a Class Java Code: class ClassName{ ...code... } Declaring a Class with Parent Java Code: class ClassName extends parentClassName{ ...code... } Declaring a class with Interface Java Code: class ClassName implements interface1, interface2, interface3{ ...code... } Declaring a Class with Fields Java Code: class ClassName{ public ...
class ClassName{ ...code... }
class ClassName extends parentClassName{ ...code... }
class ClassName implements interface1, interface2, interface3{ ...code... }
class ClassName{ public
Updated 10-18-2012 at 01:30 AM by penguinCoder
Constructors are used for initialization normally. Name of constructor should be same as that of the class. If no constructor is declared, a default constructor is created without parameters. Constructor does not return any thing. Consider the example below. ClassB inherits from ClassA. In the MainClass, we made an object of ClassB. Default constructor will be called. But the output suggests that first Constructor of ClassA is called and then the constructor of classB is called. ...