imtiazaasif

in our class java 4

Feb 7th, 2020
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 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.  
  11. public Car (String m,Double pr) {
  12.  
  13. this.model=m;
  14. this.price=pr;
  15. }
  16.  
  17.  
  18. public void display() {
  19. System.out.println("name is :"+name);
  20. System.out.println("model is :"+model);
  21. System.out.println("price is :"+price);
  22. }
  23.  
  24. public static void main(String args[]) {
  25.  
  26. Car c1=new Car("blue",100.0);
  27. System.out.println("this is second object");
  28. c1.display();
  29.  
  30. }}
Advertisement
Add Comment
Please, Sign In to add comment