0% found this document useful (0 votes)
8 views1 page

Practical 01

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Practical 01

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

2023-NOV-27 Object Oriented System Development

Classes and Objects


Practical 01
Mr. Thilina Jayathilaka

1) Check whether your machine is installed with Java.


a. Open a command prompt > type the command java > press Enter.

2) Create a folder on your desktop with your index number.


a. For example, if your index number is SC/2021/12345, your folder name should be
SC_2021_12345

3) Open a notepad window, create a class named Student, and save the file as a java file as
Student.java in your folder.

4) Add an instance variable called name of type string to the Student class.

5) Add a class variable called motto of type string to the Student class.

6) Add an instance method called printMyName() to the Student class. This method must print
the value of the variable name in the Student class.

7) Add a class method called printStudentMotto() to the Student class. This method must print
the value of the variable motto in the Student class.

8) Open a notepad window, create a class named Test, and create the main method inside the
class. Save the file as a java file as Test.java in your folder.

9) Create a student object inside the main method of the Test class. Compile and run the Test
class.

10) Assign “Kamal” to the name variable of the student object you created in the main method of
the Test class.

11) Assign “Wise & Disciplined” to the motto variable of the Student class from within the main
method of the Test class.

12) Print the name variable of the student object in the main method of the Test class.

13) Print the motto variable of the student object in the main method of the Test class.

14) Compile and run the Test class.

You might also like