OOP Important Questions
OOP Important Questions
42) What is visibility mode? What are different inheritance visibility modes supported by
C++?
43) Write a C++ program to implement the structure shown below.
Class student has data members roll no and name. Class test has data members marks1
and marks2 and Class sports has data member sports marks. Define necessary member
functions in these classes. Class result has data member for total marks. Finally display
roll no, name, marks obtained and total marks.
student
test sports
result
44) Why do we need virtual function? What are pure virtual functions? How do they differ
from normal virtual functions?
45) What is inheritance? What are its advantages? With suitable example explain single
inheritance?
46) Write a C++ program to implement the structure shown below using the concept of
virtual base class. Define necessary data members and member functions in the
respective class and finally display roll no, marks1, marks2, sports score and total result.
student
test sports
result
47) How do we define a derived class? Explain single inheritance in C++ with the help of a
program?
48) What is virtual function? List the rules for implementing virtual functions in C++.
49) What are different forms of inheritance? Explain with syntax how to define a derived
class?
50) Consider the class structure shown in figure below. Class student stores name and roll no,
class test stores marks obtained in sub1 and sub2, class result contains total marks in sub1
and sub2. Create all classes and include necessary functions to read name and roll no of
student, read marks in sub1 and sub2, calculate total marks in sub1 and sub2 and then
display it.
student
test
result
division
51) Explain the structure of a Java program and mention the steps for executing a Java
program.
52) Write a Java program to calculate area of circle.
53) What are Java identifiers? List the rules of Java identifiers.
54) Write a program in Java that accepts a series of resistances and outputs the equivalent
resistance when they are connected in series.
55) What is „this‟ keyword in Java? Write a suitable program using „this‟ keyword.
56) What is method overloading? Explain with the help of a program.
57) Write a program in Java that reads a number in meters, converts it to feets and displays
the result.
58) Explain why Java is known as a platform independent language?