0
Does creating multiple objects for a single class is useful? Or just consumes space?
2 odpowiedzi
0
Not that i meant....I'll give an example,
Class Vehicle {
Void vehicleSpeed(int s){
System.out.println(s);
}
}
public class A{
public static void main(String [] args){
Vehicle obj1=new Vehicle ();
Vehicle obj2=new Vehicle ();
obj1.vehicleSpeed(100);
obj2.vehicleSpeed(50);
}
}
In the above program, I've used 2 objects for the same class vehicle ; i can simply use obj1 for passing100 and 50; but does creating multiple objects for same class will be efficient or just consumes space?? this is my question
0
Haha