Class and Objects in Java
A class is describe the state and behaviour that objects of its type supporte.In above image is of spunchbob and chota bheem.Both are individual objects and both have its own methods.
There are 5 things to creates a class:
1. Modifiers: Keywords like public,private,protected,default. (click here for refer in details).
2. Class Name: Any name with camel case.(click here for refer in details).
3. Super Class: If class extends super class then proceed by keyword extends and then superclass name . It can be Abstract class also.Class can be extend only one class.
4: Interface: It can be using by keyword implements. One class can be implements more then one.
5: Body: It surrounded by using {} brackets.
The class is declare as:
public class Bheem{
public void Eyes(){
.......
}
.........
}
Using inheritance:
public class Bheem extends Humans{
@Override
public void Eyes(){
.......
}
.........
}
Using interface:
public class Bheem extends Humans implements Laddu,Clothes{
@Override
public void Eyes(){
.......
}
.........
}
Good... But can you please explain Syntex of class creation.?
ReplyDeletePlease describe more briefly.
ReplyDelete