IT-304 Object Oriented Programming and Methodology - Nov 2022 Question Paper
Under each question, How to answer lists the points an answer should cover, outlined by CampusPrep from the syllabus. Check the details against your textbook.
-
7 MarksaWhat is inheritance? What is the importance of inheritance? Differentiate between multilevel and multiple inheritance with suitable example.
How to answer
- Define inheritance and its importance (code reuse, extensibility)
- Explain multilevel inheritance with syntax/class diagram
- Explain multiple inheritance with syntax/class diagram
- Provide code example highlighting differences
-
7 MarksbHow is Data Encapsulation different from Information Hiding? Explain with example.
How to answer
- Define Data Encapsulation (binding data and methods together)
- Define Information Hiding (restricting access to internal state using private/protected)
- Key differences tabular comparison
- Illustrative C++ code example demonstrating both concepts
-
7 MarksaWhat is the difference between overloading and overriding? How is binding used in polymorphism? Explain with example.
How to answer
- Differentiate function overloading and function overriding (compile-time vs run-time)
- Explain early/static binding vs late/dynamic binding
- Show role of dynamic binding in polymorphism (virtual functions)
- Provide code examples illustrating both
-
7 MarksbWhat are the concepts or techniques used in object-oriented concept to handling complexity of system?
How to answer
- List key OOP techniques for complexity management: Abstraction, Encapsulation, Modularity, Hierarchy
- Explain Abstraction (managing conceptual complexity)
- Explain Encapsulation (reducing coupling, hiding implementation details)
- Explain Modularity and Inheritance/Hierarchy (decomposition and reuse)
-
7 MarksaWrite C++ function to overloaded versions of a Max function which compares two integers, two reals, or two strings, and returns the 'larger' one.
How to answer
- Define int Max(int a, int b)
- Define double Max(double a, double b)
- Define string Max(string a, string b)
- Provide a small driver main() function showing invocations
-
7 MarksbWhat is friend function? Explain application of friend function with the suitable example?
How to answer
- Define friend function and its declaration syntax with friend keyword
- Properties: non-member, can access private/protected members
- Common applications (bridging two classes, stream operator overloading)
- Complete C++ code example demonstrating its use
-
7 Marksa
Write C++ programs to validation of the examination marks is to be done. The range of exam marks is between 65 and 100 (both inclusive). This is to be done by including a validate method in Student class.
Student class +---------------------------------+ | Student | +---------------------------------+ | ...... | |---| | ...... | +---------------------------------+ | +validateExamMarks() : Boolean | +---------------------------------+How to answer
- Declare class Student with attribute for marks
- Implement setter/getter or constructor to assign marks
- Implement bool validateExamMarks() checking if marks >= 65 && marks <= 100
- Write main() to test valid and invalid mark values
-
7 Marksb
Write a class in C++ which stores the marks of 3 subjects of a student. Provide methods to set the marks and get the values of the marks. Also, provide a method called getResults(), which prints the grade of the students. Grade is calculated as shown in the table given below :
Average of 3 subjects Grade 80 to 100 A 65 to 79 B 50 to 64 C 40 to 49 D 0 to 39 E How to answer
- Define class with private members for three subject marks
- Implement setMarks(...) and getMarks(...)
- Implement getResults() calculating average = (m1+m2+m3)/3.0
- Add if-else ladder matching average to grades A, B, C, D, E
- Demonstrate working in main()
-
7 MarksaWe had several Branch Id's related to the various branches of engineering in the college. The fees to be paid are different for different branches. Write C++ programs to calculate the fees based on branch by using an array.
How to answer
- Declare arrays to store Branch IDs and corresponding fees
- Take user input for branch ID
- Search the array for the matching ID and retrieve fee
- Display the calculated fee or error if branch ID is invalid
-
7 MarksbDefine a class named Complex for representing complex numbers. A complex number has the general form $a + ib$, where $a$ is the real part and $b$ is the imaginary part ($i$ stands for imaginary). Complex arithmetic rules are as follows: $$(a + ib) + (c + id) = (a + c) + i(b + d)$$ $$(a + ib) - (c + id) = (a + c) - i(b + d)$$ $$(a + ib) * (c + id) = (ac - bd) + i(bc + ad)$$ Define these operations as member functions of Complex.
How to answer
- Define class Complex with double real and double imag data members
- Provide constructors (default and parameterized)
- Implement member function/operator+ for addition: real + c.real, imag + c.imag
- Implement member function/operator- for subtraction (note printed rule: (a-c) + i(b-d))
- Implement member function/operator* for multiplication: (ac - bd) + i(bc + ad)
- Provide display() method to print in a + ib form
-
7 MarksaWrite a class Survey Operator derived from Person. This class has the following additional members: Data Members: NumberOfCalls, NumberOfSuccessfulCalls, TotalTime, Available Operations: GetNumberOfCalls, GetNumberOfSuccessfulCalls, SetAvailable, MakeCall Define appropriate constructors for this class. Remember the fact that the base class Person does not have a default constructor and needs an explicit invocation using super().
How to answer
- Define or assume base class Person with parameterized constructor
- Define derived class SurveyOperator inheriting from Person
- Declare data members: NumberOfCalls, NumberOfSuccessfulCalls, TotalTime, Available
- Implement constructor with member initializer list invoking Person(...)
- Implement member functions: GetNumberOfCalls(), GetNumberOfSuccessfulCalls(), SetAvailable(), MakeCall()
-
7 MarksbCreate a class called Employee whose objects are records for an employee. This class will be derived class of the class Person which you will have to copy into a file of your own and compile. An employee record has an employee's name (inherited from the class Person), an annual salary represented as a single value of type double, a year the employee started work as a single value of type int and a national insurance number, which is a value of type String. Your class should have a reasonable number of constructors and accessor methods, as well as an equals method. Write a main( ) method to fully test your class definition.
How to answer
- Define class Person with name and accessors
- Derive class Employee with annualSalary (double), startYear (int), nationalInsuranceNumber (string)
- Implement default and parameterized constructors invoking Person constructor
- Implement accessor (getter) methods for all fields
- Implement bool equals(const Employee& other) comparing all fields
- Implement main() testing object creation, accessors, and equals comparison
-
7 MarksaWrite a C++ program to initialize base class members through a derived class constructor.
How to answer
- Define base class Base with private/protected member and parameterized constructor
- Define derived class Derived inheriting from Base
- Use member initialization list in Derived constructor: Derived(...) : Base(...) { ... }
- Provide main() to instantiate Derived and demonstrate base member initialization
-
7 MarksbWhat is the ambiguity that arises in multiple inheritance? How it can be overcome. Explain with example.
How to answer
- Explain ambiguity in multiple inheritance (diamond problem, duplicate member names)
- Explain resolution using scope resolution operator (Class::member)
- Explain resolution using virtual base classes (`virtual public Base`)
- Illustrate with class diagram and complete C++ program
-
14 MarksCreate a base class, Telephone, and derive a class ElectronicPhone from it. In Telephone, create a protected string member phonetype, and a public method Ring( ) that outputs a text message like this: "Ringing the <phonetype>." In ElectronicPhone, the constructor should set the phonetype to "Digital." In the Run( ) method, call Ring( ) on the ElectronicPhone to test the inheritance. For above specification to illustrate a polymorphic method. Have the derived class override the Ring( ) method to display a different message.
How to answer
- Declare base class Telephone with protected string phonetype and virtual void Ring()
- Derive class ElectronicPhone : public Telephone
- In ElectronicPhone constructor, set phonetype = "Digital"
- Override Ring() in ElectronicPhone with a custom output message
- Implement a Run() method or testing function to demonstrate dynamic polymorphism using a Telephone pointer/reference
Quick Add to Notes
Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.
Create free accountHave an account? Log in
Notes Panel