0
Object and class
describe it
4 Respostas
+ 2
A class is anything that can hold a particular kind of objects. Example , Insect is a class while cockroach is an object.
0
any code
0
Here you go,
public class insect{ //Creating a class
public String Bite(int x){ //Creating a method
do somestuff;
}
}
Now lets say I want to add an insect and use its Bite method.
then in my main method,
public class program{ //another class
public void main(String[] args){ //main method
//Now I will create an object of INSECT first namely cockroach so that i can use Bite method
insect cockroach=new insect();
cockroach.bite();
}
}
Hope it helps
0
I know its difficult to understand at first, but you will get it as you proceed. Never give up and Best of luck, my Friend.