/* related posts with thumb nails */

Class, Object, Method and Properties:

Example:

class student

{

private String name[10];

private int rno;

public void get()

{

----

}

public void show()

{

----

}

}

student s1, s2;

s1=new student();

s2=new student();

Class: Class is a collection of members where members can be member variables or member functions. Classes are used to prepare ADTs. In the above example, “student” is the class.

Object: Instances of classes are said to be objects. Members of a class are accessible by objects depending upon their accessibility conditions. In the above example, “s1” and “s2” are called “objects”.

Properties (attributes): The member variables of a class are called properties or attributes. These are also called “data members”. In the above example “name”, “rno” are properties.

Methods: The member functions of a class can be called as “methods”. In the above example “get( )”, “show( )” are methods. As the methods are public, they are accessible outside with the objects.

Related Topics:

0 comments:

Post a Comment