Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1: Code Comprehension [20%] Show the output produced by the following code. Also draw a class-level block diagram on the next page. class Student
Problem 1: Code Comprehension [20\%] Show the output produced by the following code. Also draw a class-level block diagram on the next page. class Student \{ private int sid; protected string name; public Student () ( sid =9; name = null; System, out, printin( "Empty Student"); \} public student (int id, string name) ( sid = id; this. name = name; ) public String tostring() i return sid + ": " + name; \} class CUHK extends Student ( public CUHK() ( super (-8, "Unknown"); System.out.println(this); \} public cuHK(int sid, String n ) \{ super (sid, n ) ; System.out.println(this); \} \} class CSCI extends CUHK \{ public CSCI (int sid, String n ) ( super (); name ="[ CSer ]"+n; System, out.println(this); \} \} class OnlineU extends Student ( public string tostring() 1 return "Onlineu" + super.tostring(); ) ) /* Java application Main class */ class Q1Main ( public static void main(String[] args) l new student () ; new CuHK(); new CuHk (1, "Amy"); new cscI(2,"Mike"); Student sdt = new Onlineu (); system.out.println (sdt); Student [] group = new student [4]; group [0]= new CUHK(3, "John"); group [1]=group[0]; group [2] = new cscI(4, "Mary"); group [3] = new OnlineU(); system.out . println (group [1]) ; ) \} Answer [Output of the above Java application, 12% ]: Answer [OO Diagram showing the class relationships WITHOUT objects and methods, 8\%]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started