02 Lab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Web Engineering Lab Lab 02

W e b E n g i n e e r i n g
Lab 02 Marks 100
Instructions
Work on this lab individually. You can use your books, notes, handouts etc. but you are not allowed to borrow anything from your
peer student.

Submission
Put all the files of your solution in a zipped folder labeled with your roll number.
Upload the zipper file solution(s) folder at Google classroom (https://classroom.google.com) by Saturday, March 06, 2021 11:59
PM. No submission will be accepted after this deadline.

Please use your email account at PUCIT domain and the provided code (in my earlier email) to join the Google classroom.

You are advised to upload your lab tasks in the respective section where you are enrolled; they will not be graded otherwise.

Objective
Today’s lab will help you to refresh your basic programming concepts in Java.

What you have to do


Program the following tasks in Java, compile and execute them. The name of your files will be according to the task given in this lab.

Task 1 [50]
Write a class named Student in Java with attributes rollno, name, e-mail and address. All data members must be private. Provide
constructors (default, parameterized and copy (object cloning) and setter/getter methods to initialize private data-members.
Provide the inputData() and showData() methods to input and print the information of the student.

Write a class Driver with an array for 5 elements of Student, and demonstrate its capabilities (e.g., assigning/printing data).

Task 2 [50]
Write a class Shape with data members area(double) and volume(double). This class includes the following methods:
 default, parameterized and copy constructors.
 getInput() – to get the values of data members from user using GUI components.
 toString() – override this function to display the data members.

Write the following subclasses which are extending the functionalities of Shape Class.
 Square with data members width(double), length(double), and height(double). This class must override the functionality
of super class i.e., getInput() and toString().
 Sphere with data members radius(double), and Pi (must be set to 3.14). This class must override the functionality of super
class i.e., getInput() and toString().

Write a Driver class and create 3-5 objects and test the functionality of the code.

Hint:
Area of square = ∗ , Volume of Square = ∗ ∗ , Area of Sphere = ∗ ∗ ∗ , Volume of Sphere = ∗ ∗ ∗ ∗ .

   BEST OF LUCK   

Hassan Khan, PUCIT – PU. Page 1 of 1

You might also like