0% found this document useful (0 votes)
28 views10 pages

OOP Ques

Uploaded by

Nayeem Olid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
28 views10 pages

OOP Ques

Uploaded by

Nayeem Olid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 10
Heaven Rajshahi University of BSc. Engineeri Engineering 1* Year Even Semeste Department of Light is Our Guide MRINCCrIng & Tey ‘chnology Examination, 2017 Course No: ECE 1203 “Teetrical & Computer Engineering cree Course Ohjet g eaters hject Oriented Programming (i) Bowes in eC aking THREE fom ach set page laures inthe margin Indicate full marke =f (1) Me questions are ofequtenge ak (1) Use separate answer script for each section Section - A a) What a a ( stare the unique advantages of an object-oriented program? 03 (b)__ Find errors if any, in the following C* statements ') m=5://n=10;//s-men 7 ii) cinssx>ay; iii) cout<<\n "Name:"<>AC Num>>Name;) Public void deposit void witha: oat amount cin>>amount AC Balance=AC. Balance amount; } int main(( Class Bank Account:Protected Account Bank Account account! {void check info() account deposite() {cout<>a>>b;} intsum() int mainQ{ {return(a+b);} calculator general_calc int multiply) general_cale. input) {return(a*b);) general_caleall.cale void all_calc() general_calc.display(); {a=sum();b=multiplyQ);} } void display(){cout<show(); } Page 2 of 2 se No. ECE 1203 Full Marks: 72 nih emi Mn NAB. (i) Answer SIX questions taking w (11) Figures in the margin Indie (iit) Use separate answer script Jur | Section -A Q.1 (a) What is object oriented proyranaing’? Haw is it ditterent 1 oriented programming’? fv ihe (b) Distinguish the follow terms: “ (i) Objects and classes ) Inheritance and polymorphism iii) Data abstraction and data encapsulation (©) What kind of things can become abject. in QO? How stata and method oquanized 04 in an object-oriented program’? vous Q2 (a) Explain why you must be careful when passing al objects from function, Give praper example, (b) When one object is assigned to another what pu troubles or side effects occur when ane obj ‘example. (©) What is friend function? Can a friend fietion be friend. with mere than 6 Explain with example, yJecls Low Ninetion ar cetinatnye 0 icly taken place? Can any 0% sige fs quvtluc'é expuin with Q3 (8) Describe with excimples the use of enumeration data types (b) What is a friend function? Write down ane pleat Hien finetion. uw (©) Define a class to represent a bank account, Include the fallowing features: on) Data members: 1. Name of the depositor 2. Account number 3, Type of account 4, Balance amount in the account Member functions: 1. To assign initial values 2. To deposit an amount 3. To withdraw an amount afler checking the balance, 4. To display nume and balance (d)_ When do we declare a member of a cliss stat w Q4 (@)_ Whatis the “this” pointer? m (b) Write the advantages of using reference parameter, a © In what situations copy constructor is culled’? Why is iH awccsniey'? Explain willy 04) @) example. ! Show the general forms for new and delete, What ure some iulyantayes of ati Ob them instead of mulloc() und free(), Section QS (a) Whatare the different forms of inheritun ? Clive an ex (b) How do the properties of the following two « le tar euely un ived classes (lille? “ i) class p: private x (// ii) class q: publie x (//-~ (©) Write down an example code of » paramoterized jinetion having 4 detail a argument for one parameter, Page 1 of 2 (Pind errors in the following program and state reasons. Minelindes sowtroam h> Jelass Y; public X [elas Z: clans X { ( public: public: te vol ft) void tt) xl i protected; int zt, 62, 235 int xx ab publi jut xa; 3 ‘ } . h Q.6 (a) Why an aperator is overloaded? Does it lose any of its functionality? Can the 0+ precedence of an overloaded operator be changed? (b) Write w program that overloads the unary operator *=-" in such a way that the 05 ‘operator finetion can be called by ‘object--" or *--object” and it decrements the valuo of all the private members by | of a class. (©) Explain why you might need to overload the assignment operator. Can operator =() be a fiend function, Q7 What happens when 1 protected member is inherited as (i) public (ji) private (iii) 03 protected? (b) When one class inherits another, when are the classes constructors called? When 03 ure their destructors called? (©) Explain why a virtual base class might be necessary. Give proper example. oy (4) What are the significance of the access specifiers in multiple inheritance? 02 Q.8 (n) What will be the output of the following code segment? os class office ( oid show() ( publi ; . it coute<"Exam will be started from 27th February"s| office *ptr_obj: } result ece: Mi gas reaul: public office ( ptr_obje>show()s} public: void show(){ cout<<"Reeult will be publiced soon"; ) (by When do we make a vets Fetion pure”? Why do we nec. virtual functions? oO (6) What are the finetions off) precision), i) 610, fi) setw0, iv) OCT os Heaven's L 8s Oup Guide Rajshahi University of E®gingcring & Technology B.Sc. Engineering 1" Year E¥¢ Semester Examination, 2019 Department of Electric@ & Computer Engineering Course No: ECE 1203 Course Title: Object Oriented Programming Full Marks: 72 ‘Time: 03 Hours N.B. (i) Answer SIX questions taking any THREE (70 4 section (ii) Figures in the margin indicate full matks. (ii) Use separate answer script for each section. SECTION.« SEA Q.lfa) What is the relationship of class and object? Explain Object Oriented Programming (OOP) 04 concept with some real life examples. 8) Discuss the functionality of “auto” and “decltype” with suitable coding. bos {6} Write down the output of the following code: lenore the syntax and declaration errors. " ()—intmaing) { int x =100; int y = (x++, +4x, x++): coute> x; for (int m= 0, m <& x; m+){ ‘cout << “RUET 5 Convocation - 2019” << endl; } /Q3{a)_ What is destructor? Explain default constructor calling at the time of declaring object of any 03 class with code. ae 7 : Sb) Why copy constructor is necessary? ‘Why can’t you call default constructor after declaring at 04 least parameterized constructor inside the class? Write a program to copy value of one object into another object using the concept of copy Constructor. ©) Briefly discuss about different types of inheritance in C+, 0s /Q.4G) How are the base class members initialized {tom derived class? Give an example. (b) Why is it necessary to overload an operator? Give an example. (©) Write down a C++ propram in such a way tht value++ can be used to increment each member of the class where value is an object of cass GetValue, 222 y akcriOn-® We know that a private member of @ base ¢}, js not inheritable, Is it anyway possihje GRP" hjects of a derived class to access the tte members of the base clas tn oe Remember the base class cannot be modifieg ys, how? ven do we make a class virtual? Discuss With example. ou yw type of problems may occur for hyp,ig inheritance? Discuss with example ang also 04 suggest the solution. Quah How many waysa fnetion can be overload shove with example (b) Using C++ syntax write down a program to merge two different files (student.xt, teacher.txt) o into another one (info.txt). - . (c) Whatare generalization and specialization? y,ite with examples. oe oh & What is meant by Error in programming? Differentiate between Error and Exception in C++ 03 programming. i ae ‘(o. Discuss exception handling mechanism using yry_catch block and throw keyword, 03 Af Write a program to design user defined excepyjon to handle the problem age of a valid voter, 03 (d) What will be the output of the following code? 0 int main() { intx = 10; ryt throw 10; } catch(char *str){ cout<< “Exception Handled” << endl; catch(: + )f cout<< “Default Exception” << endl; retum 0; } [Ss is UML? Mention some applications of UML in software development. 03 GY Discuss about Early Binding and Late Binding polymorphism. 02 SC what is diamond shape problem in multiple inheritance? Discuss the solution of this problem 04 ith adequate codes. yf Wit down the output of the following code. 03 class A { public: virtual void F1(){ cout<< “FI( ) from base"<< endl; void F2(){ cout << “F2( ) from base” << endl; class B: public Af public: void F1()f cout << “FI() from derive” << endl; } void F2( ){ cout << “F2( ) from derive” << endl; h int main( ){ A fay Bb; a=&b; a —>FI(); a =>F2(); } st oat ‘= = Gate — ce Scomtenaimen teri? ha a“ ii ee SECTION Smet songs) ge i ee en ph an sree teres ml prices mein sp ne enigma he et cial btm) nach eda! oa able um at C2 rac rn ht ees 9 cence hea Incr ps ‘ee Seg eww bo pe pens Den tm een iin ot Senn moe cane sist pica Coe ‘ine dole ptr om ede ah pi tral Sysco i amy mi zn nn iE tr mit he ni i eins emai crime A oy appa ang ip tegen ee Sr (Yep mapogam an nner enn ck 0 Circle O ‘ana University of ngnering and Tecmoogy (RUST) Depart fei ans amputee 8 oe cae C1208 ese ie Ose! need Prowng Scie or ae panes ‘ie said morte eH ca Saroacgeune ater ne md aricept ene prt Axe} ‘Stoanancbertan cape open mame ‘Gtonfocepton eyo pine ep . 1, ete ante ne and snow pt ta ethane ee ep pote "eos est pute racrutingare "Petes wod mar ‘se a omnes ‘Seem op , Iemenceten , ee Department of Fiesta & CompaterFnginering cna Yot_ Cue Te Objet Oren Pm Cs oe BCE: 120 ss Mas 20 Spaeth itl Mame hich dent C lowing = 1 Detine oper overlong method forthe given ls tt We cua he amon fed of te bss of Maney coetaee eae i teagan 2 punters Aching a a ce inne pam Cmchpege tte Gor tomine » Sh Sm tae pn f mae ae’ Hw Co ae ns he en ai rm (emt el Sond Sa ag pric set sas sts eis erythema reson, Ey orn se ao ‘wold dran()(coutcerberv2 Chass"«sendl;} ese % , 4 Line np fe progam sven sone Ao i 8 en fees {CLO Cogatne gy

You might also like