BASIC / NOTES</>↗Basic15 Oct 2010
Every class in Java has a constructor. constructor is a method that is used to create an instance or object of the class. Every time you create an instance, you must invoke a constructor. If you do not create a constructor method of your class, the compiler will build a default one. A default constructors […]
BASIC / NOTES</>↗Basic15 Oct 2010
Method overloading allows a method to use the same name or identifier as the method name as long as the argument list is different. Java can differentiate each method by their method signatures. For example to print some value you can create a print method that accept different kind of objects or values as its […]
BASIC / NOTES</>↗Basic14 Oct 2010
When a class extends from other class, the class or usually called as subclass inherits all the accessible members and methods of the superclass. If the subclass overrides a method provided by its superclass, a way to access the method defined in the superclass is through the super keyword. package org.kodejava.basic; public class Bike { […]
BASIC / NOTES</>↗Basic13 Oct 2010
Interface only contains methods declaration and all its methods are abstract methods. In its most common form, an interface is a group of related methods with empty bodies. To create an interface, use interface keyword in class definition. The file name of interface always the same with the interface name in class definition and the […]
BASIC / NOTES</>↗Basic13 Oct 2010
To implement an interface, a java class must use implements keyword on its class definition. For example, class A implements interface B. The class definition of class A would look like this: class A implements B { } A class can implements more than one interfaces. For example, class A can implements interface B and […]
BASIC / NOTES</>↗Basic12 Oct 2010
Inheritance is one of object-oriented programming concepts. This concept allows classes to inherit commonly used state and behavior from other classes. Inheritance is the way to put commonly used states and behaviors into one class and reuse it. The class that inherits all the attributes from other class is called as sub class. While, the […]