Task 1: Implementing Inheritance and using Default Constructors Given the following UML Class diagram: a) Create class definition for StaffUUM, Malaysian and International classes. b) Create TestStaffUUMInheritance class to run the program. c) In the TestStaffUUMInheritance class: I. Create one object for each class. Use no-argument constructors (default constructors). II. Call setter methods for each object to set their data. ...
1. Write TWO (2) different ways to create an object from the String class. - define literally (String str = “Hello!”; ) - using new operator 2. What is the output for the following Java statements? String phr = new String("Big,blue sky"); System.out.println(phr.substring(phr.indjexOf(","),7)); Ans: ,blu 3. Give your description on the output that will be produced by the execution of the following statements. Random rd = new Random(); System.out.println(rd.nextInt(41) + 10); Ans: The output will be a random number from 0 to 40 which is added with 10. 4. Write Java code segment that use class Random to generate two random numbers that is great...
TASK 1 Based on the following UML class diagram : a) Write a complete Student class. b) Next, write TestStudent class that invokes the methods of the Student class and applies the concept of an array of objects. c) Sample run as given below: User’s inputs Matric No : s1111 Test 1 : 67 Test 2 : 45 Matric No : s2222 Test 1 : 67 Test 2 : 98 Matric No : s3333 Test 1 : 67 Test 2 : 90 Program outputs ***************************** STUDENT INFORMATION ***************************** Matric No AverageMark s1111 ...
Comments
Post a Comment