Object Oriented Programming in Java

Click here to order this paper @Superbwriters.com. The Ultimate Custom Paper Writing Service

Object Oriented Programming in Java
Revised 05/25/2000

Assignment A1

Due Date: Thursday June 8th


Write a Java application that will execute the following main method and display a date in the format “month/day/year” syntax followed by your name.


public static void main(String [] args) {

// instantiate object
MyDateClass obj = new MyDateClass();

//set date values

// display date

// display name
System.out.println(“your name”);

} // end main




import java.util.*;

class MyDateClass { //define new type using keyword class

int month, day, year; // instance variables of the class

//instance method to store data
void setDate(int mo, int da, int yr) {

month = mo;
day = da;
year = yr;

}//end method setDate()

String getDate(){//instance method to get data

return “” + month + “/” + day + “/” + year;

}// end method getDate()

}//end class MyDateClass definition

//Driver program follows
class DriverProgram{ //define the controlling class

public static void main(String[] args){ //define main

MyDateClass obj = new MyDateClass(); //instantiate obj obj.setDate(5,25,00); //store data in instance variables
//display instance variables
System.out.println( obj.getDate() );
System.out.println(“My Name”);

}//end main

}//end DriverProgram class

Click here to order this paper @Superbwriters.com. The Ultimate Custom Paper Writing Service

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>