Core Java SQL Oracle PHP Examples JSP JDBC MORE

Java Object class


class:

  1. In java, a class is an extensible programing-code to creating an objects,
  2. We assume class as a sketch (prototype) of a employees. It contains all the details about the emp-id, emp-name, emp-designation etc. Based on these descriptions we create the employee status. Employee is the object.

syntax

class ClassName {
// variables
// methods
}

Example

public class Student {
public String name; //student name
public int roll_no;
public string adress{
return (name* roll_no);
}
} //end of class

Object:

  1. Every thing around the world is an object.
  2. To create an object to require class.
  3. object having two main content one is variable another is method.

Example

class car {
boolean driving;
void turnOn() {
driving = true;
}
void turnOff() {
not driving = false;
}
}
class ClassObjectsExample {
public static void main(String[] args) {
car c1 = new car(); // create l1 object of car class
car c2 = new car(); // create l2 object of car class
}
}