Oop QB (Unit 1 2 3)
Oop QB (Unit 1 2 3)
1. Define a class Student with attributes name, rollNumber, and grade. Write a method
display() to display the student's information.
2. Elaborate the concepts of java garbage collection mechanism with example
3. Demonstrate polymorphism with a Shape class that has a method draw(), and
subclasses Circle, Rectangle, and Triangle that override draw().
4. What is the difference between procedural programming and object-oriented
programming
5. Explain the role of constructors in Java programs by analyzing their function in
initializing objects, assessing their significance in facilitating object instantiation, and
evaluating their impact on the overall design and structure of object-oriented
programming
6. List the basic operators in Java (arithmetic, relational, logical). Demonstrate with
coding Example.
7. Elaborate the concept of JVM with respect to portability feature of java.
8. List the basic operators in Java (arithmetic, relational, logical). Demonstrate with
coding Example.
9. What is type casting? Give an example of explicit and implicit casting in Java with
suitable coding example
10. Create a base class Employee with attributes name and salary. Inherit it into
subclasses Manager and Developer, adding respective attributes.
Unit-II
1. Implement a superclass Person with fields name and age and a method display ().Then
create a subclass Employee that extends person and add field salary and overrides the
display () method. Show the use of super to call the superclass method from the
subclass.
2. Implement a class Circle and use inheritance to create another class Cylinder from it
Create a method for area in circle class and volume in cylinder class to print
respective area and volume.
3. Write a java program to create an interface playable with a method play() .Create a
three classes Football, Volleyball and Basketball that implements playable interface
and override play () method.
4. Apply the super keyword by creating a superclass Employee with an attribute salary.
In a subclass Manager, use super to initialize salary and add a department-specific
attribute.
5. Explain how to apply the following keywords in Java using suitable code examples:
i) static ii) final iii) this
6. Implement method overriding by creating a superclass Account with a
calculateInterest() method. Create subclasses SavingsAccount and
FixedDepositAccount that override this method.
7. Explain the difference between interfaces and abstract classes by creating
an interface Flyable and an abstract class Bird.
8. Create an inheritance hierarchy for the animals, with a superclass Animal and
subclasses Mammal, Bird, and Fish. Demonstrate the use of the super keyword to
access superclass methods and constructors.
9. Create an abstract class Vehicle with an abstract method calculateFare(int distance).
Implement subclasses Car, Bike, and Truck, each overriding the calculateFare()
method.
Unit-III
1. Develop a class in java to count the number of vowels and consonants in a given
string.
2. Design a program that performs addition of two two-dimensional arrays of the same size and
store the result in a new array. Analyze how the choice of data structure affects the
performance.
3. Implement a class which does the sum and average of 10 numbers using an array.
4. Create a Java program using ArrayList to store names of 10 students and display them
5. Write a method to remove all duplicate characters from a string using only arrays.
Analyze the efficiency and discuss alternative data structures.
6. Analyze the steps involved in creating vectors and also explain the following methods
of vector class:
i)elementAt ()
ii)removeElement(element)
iii)insert Element ()
iv)addElement ()
7. Create a program to reverse each word in a sentence while preserving the word order.
Analyze how the choice of data structure affects the performance.
8. Distinguish between LinkedList and ArrayList in terms of internal structure and use
cases.
9. Write a Java program to reverse a string using the StringBuffer class.
10. Write a Java program to multiply two 2x2 matrices.