INTRODUCTION
At an high-level, class is a structure/blueprint for an object. An object is nothing but an entity in this world.
The class is a construct for an object which actually defines the attributes (state) and methods (actions).
STRUCTURE
A class name always starts with or without access modifier 'public' and followed by 'class' keyword followed by 'Name of the Class' which is normally Camel-Case.
EXAMPLE
package jbr.oops.classdemo;
public class Dog {
// attributes
public String type;
public String legs;
public String food;
// methods
public void makeSound(){
System.out.println(“I will bark!!!”);
}
public void eat(){
System.out.println(“I will eat meat!!!”);
}
}
|
No comments :
Post a Comment