Showing posts with label object class. Show all posts
Showing posts with label object class. Show all posts

Monday, 27 July 2015

Object and Class in java

The Concept of Object and Class in Java

Object in Java

Basically an entity that has state and behavior is known as an object. It has three main characteristics like state,behavior and identity.

Object is an instance of a class.

Object and Class

Class in java

A class is a group of objects that has common properties.

A class can be defined as a template/ blue print that describes the behaviors/states that object of its type support.

Syntax to declare a class

class {  

    data member;  



Sample Program:

class FirstProgram{

   int a;     //data member
   String name;//data member
   public static void main(String args[]){  
      FirstProgram fp=new FirstProgram();  //creating an object of FirstProgram



Note: The Output of the program shows the default values in the variables 'a' and 'name'.

Wednesday, 22 January 2014

The Object class in java

what are the methods define object in java

The object class:

There is one special class, Object, defined by Java. All other classes are subclasses of Object.That is, Objectis a superclass of all other classes. This means that a reference variable of type Object can refer to an object of any other class. Also, since arrays are implemented as classes,a variable of type Object can also refer to any array.