0% found this document useful (1 vote)
961 views2 pages

Oop Medterm

The document outlines 12 programming exercises involving object-oriented concepts like classes, objects, methods, inheritance, and polymorphism. The exercises include: 1) Creating a Student class with name and roll number attributes. 2) Creating Student objects and printing attributes. 3) Creating a Triangle class to calculate area and perimeter without parameters. 4) Creating a Triangle class to calculate area and perimeter with side parameters. 5) Creating a Rectangle class with an area method. 6) Creating an Area class with setDim and getArea methods. 7) Creating an Area class with length and breadth parameters and a returnArea method. 8) Creating an Average class to calculate average of numbers. 9) Creating a Complex class with addition, subtraction and multiplication methods

Uploaded by

Alexis V. Larosa
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)
961 views2 pages

Oop Medterm

The document outlines 12 programming exercises involving object-oriented concepts like classes, objects, methods, inheritance, and polymorphism. The exercises include: 1) Creating a Student class with name and roll number attributes. 2) Creating Student objects and printing attributes. 3) Creating a Triangle class to calculate area and perimeter without parameters. 4) Creating a Triangle class to calculate area and perimeter with side parameters. 5) Creating a Rectangle class with an area method. 6) Creating an Area class with setDim and getArea methods. 7) Creating an Area class with length and breadth parameters and a returnArea method. 8) Creating an Average class to calculate average of numbers. 9) Creating a Complex class with addition, subtraction and multiplication methods

Uploaded by

Alexis V. Larosa
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

Programming practices

1.Create a class named 'Student' with String variable 'name' and


integer variable 'roll_no'. Assign the value of roll_no as '2' and that of
name as "John" by creating an object of the class Student.

2.Assign and print the roll number, phone number and address of two
students having names "Sam" and "John" respectively by creating two
objects of class 'Student'.

3.Write a program to print the area and perimeter of a triangle having


sides of 3, 4 and 5 units by creating a class named 'Triangle' without
any parameter in its constructor.

4. Write a program to print the area and perimeter of a triangle having


sides of 3, 4 and 5 units by creating a class named 'Triangle' with
constructor having the three sides as its parameters.

5.Write a program to print the area of two rectangles having sides (4,5)
and (5,8) respectively by creating a class named 'Rectangle' with a
method named 'Area' which returns the area and length and breadth
passed as parameters to its constructor.

6.Write a program to print the area of a rectangle by creating a class


named 'Area' having two methods. First method named as 'setDim'
takes length and breadth of rectangle as parameters and the second
method named as 'getArea' returns the area of the rectangle. Length
and breadth of rectangle are entered through keyboard.
7.Write a program to print the area of a rectangle by creating a class
named 'Area' taking the values of its length and breadth as parameters
of its constructor and having a method named 'returnArea' which
returns the area of the rectangle. Length and breadth of rectangle are
entered through keyboard.

8.Print the average of three numbers entered by user by creating a


class named 'Average' having a method to calculate and print the
average.

9.Print the sum, difference and product of two complex numbers by


creating a class named 'Complex' with separate methods for each
operation whose real and imaginary parts are entered by user.

10.Write a program that would print the information (name, year of


joining, salary, address) of three employees by creating a class named
'Employee'. The output should be as follows:
Name        Year of joining        Address
Robert            1994                64C- WallsStreat
Sam                2000                68D- WallsStreat
John                1999                26B- WallsStreat

11.Add two distances in inch-feet by creating a class named


'AddDistance'.

12. Create a program that with 'Animal' an abstract class and 'Dogs'.
‘Cats’ and 'Monkeys' its subclasses. The program will output as :

Dogs bark
Cats meow
Monkeys whoop

You might also like