Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Car {
- public String name;
- public String model;
- public double price;
- public Car() {
- }
- public Car(String m) {
- this.model=m;
- }
- public Car (String m,Double pr) {
- this.price=pr;
- this.model=m;
- }
- public void display() {
- System.out.println("name is :"+name);
- System.out.println("model is :"+model);
- System.out.println("price is :"+price);
- }
- public static void main(String args[]) {
- Car c1=new Car();
- c1.display();
- Car c2=new Car("model1");
- System.out.println("this is second object");
- c2.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement