Advertisement
imtiazaasif

in our class java3

Feb 7th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public class Car {
  2. public String name;
  3. public String model;
  4. public double price;
  5.  
  6.  
  7. public Car() {
  8.  
  9. }
  10. public Car(String m) {
  11. this.model=m;
  12. }
  13. public Car (String m,Double pr) {
  14. this.price=pr;
  15. this.model=m;
  16. }
  17.  
  18.  
  19. public void display() {
  20. System.out.println("name is :"+name);
  21. System.out.println("model is :"+model);
  22. System.out.println("price is :"+price);
  23. }
  24.  
  25. public static void main(String args[]) {
  26. Car c1=new Car();
  27. c1.display();
  28.  
  29. Car c2=new Car("model1");
  30. System.out.println("this is second object");
  31. c2.display();
  32.  
  33.  
  34. }
  35.  
  36.  
  37.  
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement