0% found this document useful (1 vote)
272 views

OOP - Final - LAB - Exam II A-B - Iqra Shahzad

The document provides instructions for three questions on an object oriented programming exam. Question 1 asks to create a Trigon class that inherits from GeometricShape and includes fields and methods for triangle properties. Question 2 asks to create interfaces for basic and premium music players and test them. Question 3 asks to create a GUI that converts miles to kilometers.

Uploaded by

Umar Mian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
272 views

OOP - Final - LAB - Exam II A-B - Iqra Shahzad

The document provides instructions for three questions on an object oriented programming exam. Question 1 asks to create a Trigon class that inherits from GeometricShape and includes fields and methods for triangle properties. Question 2 asks to create interfaces for basic and premium music players and test them. Question 3 asks to create a GUI that converts miles to kilometers.

Uploaded by

Umar Mian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Roll No.

_________________

NATIONAL UNIVERSITY OF MODERN LANGUAGES ISLAMABAD


DEPARTMENT OF SOFTWARE ENGINEERING
Final Term Examination – Spring 2024 – BSSE II

Subject: Object Oriented Programming Lab Time Allowed: 1:30 Hours


Total Marks: 25
Instructions:
i. Read all questions carefully before attempting.
ii. Attempt all the questions.
QUESTION 1 [CLO-2, C4, PLO-4]

[10 Marks]
Develop a java code for creating a class named Trigon inherited from the class
GeometricShape (containing a single data member named shapeName (a string) and a member
function named setShapeName(shapeName).
The class Trigon is required to hold:
1. Three data members i.e. base, perpendicular, and hypotenuse of type double
2. A no-arg constructor that initializes all data members with value 1.0
3. A parameterized constructor to initialize all data fields with user-defined values
4. The setter functions for all three data fields
5. The getter functions for all three data fields
6. A function named displayArea() (0.5*(perpendicular x base))that shows the area of a certain
Trigon object.
In the main() Class make three objects of class Trigon while considering the shapeName as
“triangle” for each object. In addition, it is required to invoke all the functions of Trigon class.

QUESTION 2 [CLO-3, C3, PLO-5]

[10 Marks]

Develop a Java code for interfaces and demonstrate their usage in the context of a music streaming service.

For this purpose your task is to

1. Make an Interface named Music:

It has methods such as play (), pause (), stop ().

2. Make another interface named PremiumMusic:

It has additional methods such as download (), createPlaylist (), and sharePlaylist ().

3. Create Classes for Implementing above Interfaces:

Implement a class BasicPlayer that implements the Music interface.

Implement a class PremiumPlayer that implements both Music and PremiumMusic interfaces.

4. Create a TestMusic Class to Test the Interfaces:

Create instances of both BasicPlayer and PremiumPlayer. Implemented methods perform appropriate actions
or output messages to display the functionality of a music streaming service from both interfaces.
Page 1 of 2
Music interface methods should display (for.eg. music is playing, pausing or stopped).

PremiumMusic interface methods should display (for. e.g., downloading, creating playlists, sharing playlists).

QUESTION 3 [CLO-3, C3, PLO-5]


[5 Marks]

Develop the Java program to implement GUI given in Figure 1 by using AWT/Swing classes.

 Above interface is Java GUI application to convert miles to kilometers when pressing the
"Convert!" button.
 Note that 1 mile is equal to 1.609 kilometers.

Page 2 of 2

You might also like