Java

345
4863 reads

January 11, 2013

inheritance


The below program demonstrates how to use Inhertitance in java. The below program defines a Super Class named Auto which is extended by two Derived Class named EuropeanAuto & JapaneseAuto.

376
3656 reads

January 11, 2013

Static Methods


The below program demonstrates how to define a static method and call it. It defines a static method getMyStaticInt() which returns a static variable value and is accessed by the class name.

33
2346 reads

January 11, 2013

Method Parameters


The below example demonstrates how to use method in java. The below example defines a function named f() which takes Class Letter Object as parameter and assigns value for object variable c.

29
2460 reads

January 11, 2013

Defining Methods


The below example demonstrate how to define a method and call it. The below example defines a method named volume() which returns 50 when invoked.

70
2351 reads

January 11, 2013

Calories Example


The below example demonstrates how to use Protected Modifier in java.

184
2552 reads

January 11, 2013

This Example


The below example demonstrates how to use "this" keyword in java. The below example uses this keyword to refer to the object instance variable.

219
2530 reads

January 11, 2013

Comparing Two Objects ( Employee Example))


The below example demonstrates how to compare two objects of same class in java.

241
4054 reads

January 11, 2013

Superclass


The below example demonstrates that all classes descend from the type java.lang.Object. The below example allows the user to view the superclass of class SomeClass, SomeOtherClass as output.

48
2304 reads

January 11, 2013

Writing a Class with State and Behaviour


The below example demonstrate how to write a class with state and behavior in java.

323
4129 reads

January 11, 2013

Multiple Constructors Example


The below program demonstrates how to define multiple constructors for a class in java.