Вы находитесь на странице: 1из 3

Assignment questions

Course: Object Oriented Programming (15CS2002)

Course Outcome: CO3

(Group-A)

Questions from: co3-i1


1. Develop a super class having two instance variables and two methods, write a
derived class for the above which has access to three instance variables and access
to three methods. Give demonstration?
2. Develop a java program that implements multi level inheritance with three classes,
demonstrate ?
3. Declare the School class to describe a school. Declare the University class to describe
a university. The University class should extend the School class. Think about the
different variables and methods (constructors as well) that should be declared in
each one of the classes. Test the classes that you declared using a stand-alone
application (another separate class).
4. Develop a program to create a class named shape. In this class we have three sub
classes circle, triangle and square each class has two member function named draw
() and erase (). Create these using polymorphism concepts.
5. Declare the Bus class to describe a bus. Declare the Car class to describe a car. The
Bus class should extend the Car class. Think about the different variables and
methods (constructors as well) that should be declared in each one of the
classes. Test the classes that you declared using a stand-alone application (another
separate class).
6. Develop a program to display sum of two integer variables with an object of Adder
class which extends the add() method from Arithmetic class, this class does not have
its own elements. add method signature is int add(int, int);

(Group-B)

Questions from: co3-i2


1. What are the differences between abstract class and concrete class? Develop code
segment?
2. Apply dynamic method despatch with abstract and its concrete class? Give example
program?

3. Define an Abstract class named Drink which defines the following methods:
a. Constructor with two parameters: serialNo (drinks serial number) and description
(brief description about the drink). A drink has a sugarContent which is by default is
0.

b. toString method that prints the serial number followed by the description and the
sugar content of the drink.

c. An increaseSugarContent method that allow us to increase the sugar content by a


particular integer amount. For example, if p is a concrete class that extends Drink,

+p.increaseSugarContent(10).increaseSugarContent(20);

d. An abstract method named getIngredients which returns a string with the drinks
ingredients.

4. Consider the following Book class


one string variable title
one abstract method void setTitle(String s)
one concrete method String getTitle()
Develop a program to extend the properties of abstract class Book to MYBook class.
Create an object to MyBook class in MyBookDemo class read title with setTitle()
method and display title with getTitle() method.

5. Declare the JavaProgrammer abstract class to describe a java programmer. Declare


the JavaDevelopper class to describe a java developer. The JavaDevelopper should
extend the JavaProgrammer class. Declare the JavaArchitect class as a class that
describes a java architect and extends the JavaDeveloper. Think about the different
variables and methods (constructors as well) that should be declared in each one of
the classes. Test the classes that you declared using a stand-alone application
(another separate class).

6. What are access modifiers, explain? Develop a java program That access protected
member of a Base class from a different package by its derived class object?

(Group-C)

Questions from: co3-i3


1. Develop a program to create a package with the name pack and store Addition class
in it, in Addition class initialize instance variables with passed parameters and find
the sum of two double variables by using sum() function. Give commands how to
compile and execute?
2. Use dynamic method despatch in the context of interface and concrete class?
Consider atleast one method and one constant in interface and atleast two methods
and two variables in the class. Write a deriver class to demonstrate this concept?
3. Develop a program to create interface named test. In this interface the member
function is square. Implement this interface in arithmetic class. Create one new class
called ToTestInt in this class use the object of arithmetic class.
4. What is extends key word in connection with interfaces? Demonstrate this concept
with any two interfaces and one concrete class?
5. Multiple inheritance in java is not possible, Develop a program to give example for
multiple inheritance in Java using class and interface.
6. Create an interface that has methods and a constant. Create an abstract class with
an abstract method, a non abstract method, and an instance variable. Create a
concrete class that uses both of the above.

---------------- end of assignment-----------------------

Вам также может понравиться