Professional Documents
Culture Documents
SET C
Course Articulation Matrix:(to be placed)
Sl.No Course
. Outcomes PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 P10 P11 P12
1 CO1 - 2 2 - 2 - - - - - - 3
2 CO2 - 2 2 - 2 - - - - - - 3
3 CO3 - 2 2 - 2 - - - - - - 3
4 CO4 - 2 2 - 2 - - - - - - 3
5 CO5 - 2 2 - 2 - - - - - - 3
Q. MCQ Marks BL CO PO PI
No Code
1 Consider the base class “Shape” . The classes 1 4 3 2 2.1.3
“Triangle”, “Circle”, and “Square” are derived from
the base class. Which of the following is incorrect
derivation?
a. class Triangle: public Shape
b. class Circle: public Shape
c. class Shape: public Triangle
d. class Square: public Shape
#include <iostream>
int main()
{
Base *p = new Derived;
Derived *q = new Base;
}
a. error: invalid conversion from
"Derived*" to "Base*"
b. No Compiler Error
c. error: invalid conversion from
"Base*" to "Derived*"
d. Runtime Error
7 A virtual function is redefined in which of the 1 1 3 3 2.4.1
following class?
a. Derived class
b. Parent class
c. base class
d. Both A and B
8 In late binding, the function call is resolved during? 1 2 3 2 3.3.1
a. runtime
b. Compile time
c. Infinite time
d. Load time
9 In an Activity Diagram, organizing the activities into 1 1 3 5 5.1.1
groups is called ________
a. forking
b. joining
c. swimlane
d. synchronization
10 ________ is used to represent concurrent flows in an 1 1 3 5 5.1.2
Activity Diagram
a. slide bar
b. synchronization bar
c. swim lane
d. branch
11 It is a specialised form of the Uml class diagram. 1 2 4 2 1.3.1
a. Package Diagram.
b. Component Diagram.
c. Activity Diagram.
d. Deployment Diagram
12 Identify the program output 1 2 4 2 1.3.1
#include <iostream>
using namespace std;
template <class T, class U>
class A { T x; U y; static int count; };
int main()
{ A<float, float> p;
A<int8_t, int8_t> q;
cout<<sizeof(p) <<endl; cout<<sizeof(q) <<endl;
return 0; } a. Syntax error
b. 8 8
c. 8 4
d. 8 2
13 What can non-type template arguments pass during 1 1 4 2 2.1.2
compilation?
a. Char.
b. int
c. float
d. constant expression
14 How is the C++ program's exception handling 1 1 4 1 1.4.1
implemented?
a. by try-catch block.
b. by Exception block
c. by Exception keyword
d. by Error Handling methods
15 An issue that occurs when a programme is being 1 1 4 3 2.4.1
executed is called as _____
a. Templates
b. Exception
c. Syntax Error
d. Semantical Error
16 Identify the program output 1 2 4 2 3.3.1
#include <iostream>
using namespace std;
template <typename T>
T max (T& p, T& q)
{ return (p<q?p:q); }
int main ()
{ int x = 55, y = 60, m;
long a = 105, b = 53, n;
m = max(x, y);
n = max(a, b);
cout<< m <<endl;
cout<< n <<endl; return 0; }
Which one will be correct?
a. 60,105
b. 55,53
c. 53,55
d. 105,55
17 In Component Diagram, Components 1 2 4 5 5.1.1
communicate with each other using which of
the following?
(A). Components
(B). interfaces
(C). Use cases
(D). attributes
a) Notes
b) Box
c) Extension Mechanisms
d) Packages
19 To define a custom exception, which header file need 1 2 4 3 3.3.1
to be included
a. except
b. exception
c. userexcept
d. iostream
20 Which returns the cause of a user defined exception? 1 2 4 3 2.4.1
a. what()
b. try block
c. catch block
d. exception class
SET C
Example:
class pet
{
private:
char name[5];
public:
virtual void getdata()=0;
virtual void display()=0;
};
class fish : public pet
{
private:
char environment[10];
char food[10];
public:
void getdata();
void display();
};
class dog: public pet
{
private:
char environment[10];
char food[10];
public:
void getdata();
void display();
};
void fish::getdata()
{
cout<<"Enter the Fish Environment required"<<endl;
cin>>environment;
cout<<"Enter the Fish food require"<<endl;
cin>>food;
}
void fish::display()
{
cout<<"Fish Environment="<<environment<<endl;
cout<<"Fish Food="<<food<<endl;
cout<<"------------------"<<endl;
}
void dog::getdata()
{
cout<<"Enter the Dog Environment
required"<<endl;
cin>>environment;
cout<<"Enter the Dog Food require"<<endl;
cin>>food;
}
void dog::display()
{
cout<<"Dog
Environment="<<environment<<endl;
cout<<"Dog Food="<<food<<endl;
cout<<"---------------------------------------"<<endl;
}
void main()
{
pet *ptr;
fish f;
ptr=&f;
ptr->getdata();
ptr->display();
dog d;
ptr=&d;
ptr->getdata();
ptr->display();
getch();
i) Synchronous Exception
"Occur during the program execution due to
some fault in the input data or technique that is not
suitable to handle the current class of data, within the
program .
For example:
errors such as out of range
Overflow
underflow and so on"
ii)Asynchronous Exceptions
For example
errors such as keyboard interrupts
hardware malfunctions
disk failure and so on
#include <iostream>
using namespace std;
public:
ClassTemplate(T v1, U v2, V v3) : var1(v1),
var2(v2), var3(v3) {} // constructor
void printVar() {
cout<< "var1 = " << var1 <<endl;
cout<< "var2 = " << var2 <<endl;
cout<< "var3 = " << var3 <<endl;
}
};
int main() {
// create object with int, double and char types
ClassTemplate<int, double> obj1(7, 7.7, 'c');
cout<< "obj1 values: " <<endl;
obj1.printVar();
return 0;
}
22 The online shopping system offers a function that will 10 2 4 5 5.1.2
A significantly assist both buyers and sellers when
doing online shopping. Draw a Swimlane Activity
Diagram for Online Shopping System to see the
activities between the customer and the shopping
system.
OR
22 For an Online Bike Service Booking system draw the 10 2 4 5 5.1.2
B statechart and the component diagrams.
PART – C (1*10=10 Marks)
SCENARIO BASED/HOTs
23 Indian Electoral Office wants to update the details of 10 3 3 5.1.2 5.1.2
A voters in their portal. Write a C++ program that
prompts the user to enter their age and then checks if
the age is a valid number between 18 and 100. If the
age is not within this range, an exception is thrown,
which is caught by the catch block, which prints an
error message. Define the custom exception
'NotValidAge' to implement the same.
#include <iostream>
#include<exception>
#include<string>
using namespace std;
class NotValidAge: public exception{
public:
virtual const char* what() const throw(){
return "User age required to have 18 age to
become Indian Voter";
}
};
int main() {
NotValidAgeageex;
try
{
int age;
string name;
cout<<"Enter the name of the Person:";
cin>>name;
cout<<"Enter the age of the Person :";
cin>>age;
if(age<18)
throw ageex;
else
cout<<name<<" is an Indian Voter. Welcome!";
}
catch(exception& e)
{
cout<<e.what();
}
return 0;
}
OR
23 Create a class named Shape with a function that prints 10 2 4 5 5.1.1
B "This is a shape". Create another class named Polygon
inheriting the Shape class with the same function that
prints "Polygon is a shape". Create two other classes
named Rectangle and Triangle having the same
function which prints "Rectangle is a polygon" and
"Triangle is a polygon" respectively. Again, make
another class named Square having the same function
which prints "Square is a rectangle".
Now, try calling the function by the object of each of
these classes.
#include <iostream>
using namespace std;
class Shape{
public:
Shape(){}
virtual void print(){
cout<<"\nThis is a shape.";
}
};
class Polygon: public Shape{
public:
Polygon(){}
void print(){
cout<<"\nPolygon is a shape.";
}
};
class Rectangle: public Polygon{
public:
Rectangle(){}
void print(){
cout<<"\nRectangle is a Polygon.";
}
};
class Triangle: public Polygon{
public:
Triangle(){}
void print(){
cout<<"\nTriangle is a Polygon.";
}
};
class Square: public Rectangle{
public:
Square(){}
void print(){
cout<<"\nSquare is a Rectangle.";
}
};
int main(){
Shape S;
Polygon P;
Rectangle R;
Triangle T;
Square Sq;
S.print();
P.print();
R.print();
T.print();
Sq.print();
return 0;
}