0% found this document useful (0 votes)
16 views15 pages

Oop With Java

OOP WITH JAVA

Uploaded by

pksmadhu4
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)
16 views15 pages

Oop With Java

OOP WITH JAVA

Uploaded by

pksmadhu4
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/ 15

OOP WITH JAVAVA

SUBJECT CODE- CBT1422

NAME PRERNA PATEL

ENROLLMENT NUMBER 230160203018

FACULTY NAME VAISHALI ARYA

SEMESTER/SESSION 2ND
SECTION C
EXPERIMENT-1

1.(a) Write a program asking user to input his/her age.


Print “You are allowed to vote” if the age>=18; otherwise
print “You are not allowed to vote”.

OUTPUT
EXPERIMENT-2
(b) Write a program asking users to input character grades- A, B, C or F.
Use switch case to print:

“You are excellent” if user enters A

“You are good” if user enters B

“You are average” if user enters C

“You are fail” if user enters F.


OUTPUT
EXPERIMENT-3
Write a program to illustrate 1D and 2D arrays,

OUTPUT
EXPERIMENT 4
a) Write a program to create a class Rectangle which has a
(
method area(). area() returns the area of the rectangle.

OUTPUT
EXPERIMENT 5
A) Create a class named Student with String variable name
and integer variable roll_no. Assign the value of roll.no as 100
and that of name as "Akshay" by creating an object of the class
Student.

OUTPUT
EXPERIMENT-5

B)

Create a class “Employee” having attributes “name” and


“salary”. Calculate bonus of each employee(bonus is 10%
added to the salary). Print the name, salary and bonus of
employee. Supply the value of attributes through constructor.

OUTPUT
EXPERIMENT-6

Write a program to create a class Overloading. It has a


method greater() which calculates the greater of two integer
numbers. Overload the method greater() to now calculate the
greater of two double number

OUTPUT
6. Design a class hierarchy rooted in the class Student that includes two subclasses-

EXPERIMENT -7

FullTimeStudent and PartTimeStudent. Both the subclasses share the attributes -


name, programme, noOfCredits(2-4), GPA(0-5). The PartTimeStudent has an extra
attribute - PracticalGradeScore(0-5). Create methods in both the subclasses to
calculate and print CGPA of the students. CGPA for FullTimeStudent =
noOfCredits * GPA; CGPA for PartTimeStudent = noOfCredits * GPA +
PracticalGradeScore.
8. Write a program to create a class Employee that includes a method
calcsalary(). calcsalary() calculates the salary using baseSalary + HRA
+ DA. The subclass SalesEmployee overrides the calcsalary() to
calculate salary using baseSalary + HRA + DA +variablePay.
9. Create an interface Shape1 with two methods namely RectangleArea(taking two
parameters- length and breadth) and SquareArea(taking one parameter- side).
Create another interface Shape2 with one method namely CircleArea(taking one
parameter-radius). Create a class Area that implements both Shape1 and Shape 2.
containing all the three methods RectangleArea, SquareArea and CircleArea
'printing the area of rectangle, square and circle respectively.

You might also like