0% found this document useful (0 votes)
904 views4 pages

OODJ Test 2 Questions

The document contains a practice exam with 3 questions for an object-oriented development with Java course. Question 1 (10 marks) involves developing a class diagram for a football tournament scenario. Question 2 (10 marks) analyzes output from code involving inheritance between vehicle classes. Question 3 (5 marks) involves filling in missing code elements to copy a file.

Uploaded by

Xetrini chhetri
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)
904 views4 pages

OODJ Test 2 Questions

The document contains a practice exam with 3 questions for an object-oriented development with Java course. Question 1 (10 marks) involves developing a class diagram for a football tournament scenario. Question 2 (10 marks) analyzes output from code involving inheritance between vehicle classes. Question 3 (5 marks) involves filling in missing code elements to copy a file.

Uploaded by

Xetrini chhetri
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/ 4

Object-oriented Development with Java (CT038-3-2) Page 1 of 4

Test 2 (Total: 25 marks)


Answer ALL questions from this test

Question 1

Develop a class diagram identifying the attributes, methods and cardinalities for the
following scenario:

Malaysian Football Association is organising a Tournament for various University


football teams to participate. Each Tournament can take maximum of 10 teams.
Each team can bring 12 players for the tournament. Each player has a specific
height, speed, accuracy and a team for which they play. Some players are
scholarship players. Scholarship players need to record their current grade-point
average. Players may be transferred between teams. Each team play games against
other teams in the tournament.

(Total: 10 marks)

This study source was downloaded by 100000827704856 from CourseHero.com on 07-08-2022 20:26:30 GMT -05:00

https://www.coursehero.com/file/38269267/OODJ-Test-2-Questionsdoc/
Object-oriented Development with Java (CT038-3-2) Page 2 of 4

Question 2
Observe the classes given below:

class Vehicle
{
public void a()
{
System.out.println("Vehicle a");
}
public void b()
{
System.out.println("Vehicle b");
}
}

class FourWheelVehicle extends Vehicle


{
public void b()
{
System.out.println("FourWheelVehicle b");
a();
}
}

class FrontWheelDrive extends FourWheelVehicle


{
public void b()
{
System.out.println("FrontWheel b");
super.b();
}
public void c()
{
System.out.println("FrontWheel c");
}
}

class FourWheelDrive extends FourWheelVehicle


{
public void a()
{
System.out.println("FourWheelDrive a");
}
public void c()
{
b();
System.out.println("FourWheelDrive c");
}
}

` CONTINUE NEXT PAGE 

This study source was downloaded by 100000827704856 from CourseHero.com on 07-08-2022 20:26:30 GMT -05:00

https://www.coursehero.com/file/38269267/OODJ-Test-2-Questionsdoc/
Object-oriented Development with Java (CT038-3-2) Page 3 of 4

Given the classes above (Page 2), what output is produced by the following code?

Vehicle POLO = new FrontWheelDrive();


FourWheelDrive HondaCRV= new FourWheelDrive();
FourWheelVehicle VIOS= new FourWheelVehicle();
POLO.a();
POLO.b();
HondaCRV.a();
HondaCRV.b();
VIOS.a();
VIOS.b();

(Total: 10 marks)

This study source was downloaded by 100000827704856 from CourseHero.com on 07-08-2022 20:26:30 GMT -05:00

https://www.coursehero.com/file/38269267/OODJ-Test-2-Questionsdoc/
Object-oriented Development with Java (CT038-3-2) Page 4 of 4

Question 3

Given the following Java code, fill the missing gaps with the appropriate keyword/
command/value:

package filesdemo;
import java.io.*;

public class FileDemo


{
public static void main(String args[])
{
FileInputStream in = null;
FileOutputStream out = null;
try
{
in = new <___i___>("input.txt");
out = new <___ii___>("output.txt", true);
<___iii___> c;
while ((c = in.<___iv___>) != -1)
{
out.write(c);
}
}catch (FileNotFoundException e1)
{
System.out.println("An Exception thrown because ");
}
<___v___> (IOException e2)
{
System.out.println("reading data error. ");
}
finally {
if (in != null)
{
in.close();
}
if (out != null)
{
out.close();
}
}
}
}

(5 marks)

<<END OF PAPER>>

This study source was downloaded by 100000827704856 from CourseHero.com on 07-08-2022 20:26:30 GMT -05:00

https://www.coursehero.com/file/38269267/OODJ-Test-2-Questionsdoc/
Powered by TCPDF (www.tcpdf.org)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy