0% found this document useful (0 votes)
14 views

Test 1 Oop

The document contains 4 questions regarding object-oriented programming concepts in C++. Question 1 asks about writing correct statements for equations and defining a class template for a phone class. Question 2 asks about writing a function template to insert an element into an array and determining the output of a sample program. Question 3 asks about declaring and initializing a static data member of a class and filling in blanks regarding friend classes and functions. Question 4 asks about finding errors in code samples and answering true/false statements about constructors and destructors.

Uploaded by

al_badwi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Test 1 Oop

The document contains 4 questions regarding object-oriented programming concepts in C++. Question 1 asks about writing correct statements for equations and defining a class template for a phone class. Question 2 asks about writing a function template to insert an element into an array and determining the output of a sample program. Question 3 asks about declaring and initializing a static data member of a class and filling in blanks regarding friend classes and functions. Question 4 asks about finding errors in code samples and answering true/false statements about constructors and destructors.

Uploaded by

al_badwi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

[OOP TEST #1 ] 1# (a) Write the correct statements for these equations;

3 /12/ 2012

10 R 60

if ( x 12) if ( x 12)

(b) Define a class template for the PHONE class containing a name of the person, his mobile phone number, and his email address. Include a constructor and any friend method. Draw the Class Diagram? 2# (a) Write a function template that inserts an element in the Kth position of an array A of size n and any type. (b) What is the output from the following program?
#include <iostream> using namespace std; void Fn() { static int b = 5 ; b ++ ; } int main() { int a = 7 ; Fn(); cout << a ; return 0 ; }

3# (a) How do you declare and initialize a Static data member of a class? (b) Fill in the blanks with the appropriate words: (i) A class C is declared as friend of class B in the body of class B. With this declaration, class B ...a friend of class C. (becomes, does not become) (ii) A friend function to a class has access to .... members of a class. (only public members, only private members, all members) 4# (a) Find the error(s) in the following code? Or write No Error (i) class sample1 { float a, b, c ; public : void sample1( ) ; }; (ii) class sample2 { float a, b, c ; sample2( ) ; };

(b) TRUE or FALSE: The constructor and the destructor can be overloaded. TRUE or FALSE: A destructor does not accept any arguments. TRUE or FALSE: A default copy constructor is created automatically by compiler.

You might also like