0% found this document useful (0 votes)
9 views1 page

Practical Assignment 2

Uploaded by

ggp8mjcbwy
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)
9 views1 page

Practical Assignment 2

Uploaded by

ggp8mjcbwy
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/ 1

Practical Assignment – 2

B.C.A./B.Sc.I.T.
Semester – 3
23UGCA301/23UGCS301
Object Oriented Programming with Java
Inheritance & Packages
1. Define a class University having instance variable uname, ucity and tot_stud. Define
getUni() method to initialize instance variable. Define derived class Department having
instance variable deptno and deptname. Define getDept() method to initialize instance
variable. Also define display() method to display all information. Create two objects and
demonstrate.

2. Define a class University having instance variable uname, ucity and tot_stud. Define
parameterized constructor to initialize instance variable. Define derived class
Department having instance variable deptno and deptname. Define parameterized
constructor to initialize instance variable. Also define display() method to display all
information. Create two objects and demonstrate.

3. Create a Shape class as the abstract class with abstract method draw( ), its implementation
is provided by the Rectangle & Circle classes. Create a reference of Shape class and if you
create the instance of Rectangle class, draw() method of Rectangle class will be invoked.
And same for Circle class. (Dynamic Method Dispatch)

4. Create two interfaces Printable and Showable having methods print( ) and show( )
respectively. Create a Test_Multiple class which implements all 2 interfaces and override
print( ) and show( ) methods. Write a main method in this class and create an object of this
class and use the methods.

5. Write a program that finds the length of the string “Java Programming”. And also display a
sub-string formed by the last five characters of the string. ( use String class)

6. Write a program to do the following using in-built methods in the string class of java.
a. Find the 3rd character in the string "Atmiya University"
b. Find the index of character ‘o’ in string "Java Programming".
c. Convert the string "Enjoy Holiday" to uppercase.
d. Replace character 'H' with 'n' in the string "Hello… Hi..”.

7. Perform following operation on string "Java is simple language."


- print the string
- find the length of the string
- convert string into uppercase
- convert string into lowercase
- find the index of character 's'
- replace character 'a' with 'b'
- replace "is" with "was"
- Find substring from index no 15
- Find substring from index no 15 to 18.
- Check whether string starts with "J" or not.
- Check whether string ends with "j" or not.

You might also like