×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Java Introduction (Basic Concept) Java Examples : if-else Programs
What are classes and objects in java. - Java
4351    Arnab De    20/05/2017

Objects are the real entity in the world and class is the framework of objects. Therefore we can say classes and objects are interrelated topic in real life and java. Any member of the class can access by the objects of that class. only static member of the function can access through the class name.Static variable are known as class variable and a non-static variables known as object variables.

What is object?

Any real entity of the world which has its own unique characteristic, state and behavior are called an object.

Ex. a Pen, a ball, you, me, a cat, a chair, a TV etc.

Examples of Objects
Examples of Objects

What is class?

Class is a collection of same types of objects. We can declare a class by the keyword class.

softetechnologies

Ex. All of us are belongs to the Human class. In other words any objects of the Human class are refer a person of the world.

Java class consist two parts

  1. Member variables: These variables are holds the value which determine the state and behavior of the class objects.
  2. Member function or method: These methods are used to control the member variable and perform different logics.

Note : Every Java Program should write with in a class. And we can access the member variable and member function by using the object of that class.

Procedure of writing class name

  1. Class name always start with alphabet.
  2. No Special character allowed.
  3. If class name is in one word the first character must be capital and others letter must be small. Let the class name is draw, then it should be write as Draw not draw.
  4. If class name have multi word then first character of each word should be Capital and no space allowed in between the words. Let the class name is draw line, then it should be write as DrawLine not Draw Line or Drawline.
softetechnologies

Program Example

Here we create a class called Human. And also we create the object of that class from another class called AccessHuman

class Human
{
private int age,height;
public void setValues(int a,int h);
{
age=a;
height=h;
}
public void getValues()
{
System.out.println(“Your Age is “ + age);
System.out.println(“Your Height is “ + height);
}
}

class AccessHuman
{
public static void main(String []args)
{
Human h1=new Human(); // Object Creation
h1.setValues(15,4); // Access Methods
h1.getValues(); // By Object
}
}

What is the difference between an object and a class? [ICSE 2011]

Class Object

A class is a blueprint of a real world object. It contains instance variables and methods.

An object is an instance of a class.

A class exists in the memory of a computer.

An object does not exist in memory in a computer.

There will be only one copy of a class.

Multiple objects can be instantiated from the same class.

Java Introduction (Basic Concept) Java Examples : if-else Programs
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Swami Vivekananda
Education is the manifestationof the perfection already in man.
Swami Vivekananda
3221
57.29
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     43551
01/01/2018     36485
25/06/2018     35498
28/06/2017     34551
02/08/2017     32982
01/08/2017     27463
06/07/2017     27212
15/05/2017     26845
14/07/2017     22461
21/04/2018     21111
softetechnologies