Professional Documents
Culture Documents
Programming Language 2
Computer Science Department
2022
Lab Objectives:
In this lab, a student will practice
• In this lab, the student will practice: • Declaring accessors and mutators
• Creating a class declaration. methods.
• Declaring instance variables. • Writing a test application to
• Declaring a constructor. demonstrate the capabilities of another
• Overloading constructor. class.
• Reading part of a UML class
diagram/access modifier.
Lab Exercise 1:
Based on the UML class diagram below, create the needed instance variables, set and get
method and constructors; then write a test application to demonstrate the classes
capabilities.
Exam
- ExamName: String
- ExamNo: int
- Difficulty: boolean
- ??????????????
+ << all setter>>
+ <<all getter>>
+ <<Constructor>> Exam( )
+ <<Constructor>> Exam (int ExamNo ,String ExamName )
+ checkDifficulty ( Difficulty: String) : void
+ ????????????????
Write a Java program that models the properties and behaviours of any object from your
choice. Note: Animal, Person, Student, and Customer are not accepted as answer.
Write maximum 4 properties, and at least 1 behaviour. All fields must be private. Provide
getter and any necessary setter methods and one constructor.
You’ll also need a test class that contains a main method to create objects of the class.