Object Oriented Programming Masters of Computer Science

Class and Objects in Java

Class and Objects in Java


  • user-defined blueprint in OOP
  • a common set of properties are represented by class
  • To create a class, you need to use the keyword class

Class named “Test” is created below
public class Test {
int x=17;

  • Class describes state and behavior

Remember, class is blueprint form where individual objects are generated


public classCat {
   String breed;
   int age;
   String color;

   void mew() {

   void sleep() {

   void run() {


  • the basic unit of OOP
  • real-life entities are represented by the object
  • In java, an object is created from a class
  • Objects have state and behaviour. For example, a cat has a state and behaviour
    • States like: Color, name, breed of the cat
    • Behaviour like: mewing, moving tail etc
About Author

ICT Byte