Q1_20251109103739.webp
May76

Q1_20251109103739.webp

  • Media owner May76
  • Ngày thêm
Question 1:
(2 marks) Read PE instructions at the bottom of the exam paper.
Do not pay attention to real meaning of objects, variables and their values in the questions below.
Write a class named Student with the following information:
Where:


Student
- name:String
-gpa: double
+Student()
+Student(name: String, gpa: double)

+getPass(): String
+setName(lastname:String)
+toString():String
The program output might look something like:
Enter name: hoa
Enter gpa: 5.4
1. Test setName()
2. Test getPass()
Enter TC (1 or 2): 1
Enter lastname: nguyen
OUTPUT:
hoa nguyen, 5.4
Student () default constructor.
Student(name: String, gpa: double)- constructor,
which sets values for all attributes.
getPass: String return "pass" if gpa>=5.0
otherwise return "fail".
setName(lastname:String) - return the name with
the first letter in uppercase.
.toString()) return String with format name, gpa
Do not format the result.
Enter name: lan
Enter gpa: 4.5
1. Test setName()
2. Test getPass()
Enter TC (1 or 2): 2
OUTPUT:
fail
Zoom
- FUO
Question 2:
(3 marks) Write a class Car and a class SpecCar extending from Car (i.e. Car is a superclass and
SpecCar is a subclass) with the following information:
Car
+ 100%
Where:
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
May76
Ngày thêm
Lượt xem
631
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom