Showing posts with label constructor in java. Show all posts
Showing posts with label constructor in java. Show all posts

Sunday, May 7, 2017

Constructor in Java

Here is a very simple implementation of constructor in Java. Constructor is very important in creating an object in object oriented programming in Java. The code is very short and easy to understand. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

package demo;

class Car {
 void Model_Car() {
System.out.println();
System.out.println("Constructor Demo in Java");
System.out.println();
System.out.println("I am driving a Toyota Corolla Model 2017.");
  }
}

public class Constructor {

public static void main(String[] args) {
    
    Car Toyota = new Car();
       
    Toyota.Model_Car();

}

}