Test 2 Flashcards

0
Q

In C++ what is the difference between a struct and a class?

A

the deaufult access specifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

What is the primary valve in using virtual functions within C++?

A

They allow you to provide unique behavior for derived classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the point in making a destructor “virtual”?

A

It causes the derived class destructor to be called upon delete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which statement is true of “pure virtul” functions?

a) They force you to derive another class from the base class which contains function.
b) They contain no code

A

Both of these

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

If two functions within the same classhave the same name what happens?

A

either one will be called depending on the parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
What is wrong whit the following?
struct Svalues (char x .....x = 25 y = 30
class C values (...)          x = 25 y = 30
A

Private members of a class are being accessed by other than a member/ friend function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Is the following class definition correct?

class point
{ int x,y;
void point():
void point (int n, int m); };
A

It is not correct, construction can not return any value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Suppose that we declare an array int ARR [10] and perform the following instruction ARR[10]=10.7. What is the value stored in the 10th array element?

A

We can not predict

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Consider the following class definition. Which of the presented definitions is correct?

class point
{int x;
const int y;
public:
point (int n, int m);};
A

y (m) {x = n}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

consider the following class definition

class A {public:
int x;
const int y;
static int z;
A(int xx, int yy, int zz); };
                                          Is this correct?
A(int xx, int yy, int zz) : y(yy), z(zz)
{x=xx}
A

No, static members can not be initialized at initialization list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Consider the following class sequence. Determine type of acces to member x1,x2,y1,y2

class x1
{intx1;
public:
int y1; };....
A

x1,x2,y2-private, y1 - public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Consider the following coder frgment. Which exception handler will be used ?

try {int number 7;
throw number;}
catch (const int a) {first}….

A

First

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
The following class template has been defined:
template 
which of the defined below template class is correct
A

test ob1;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
The following function has been definied
void test(int y, float z =6.55,intk,inti=0)
which of the specified below function calls is correct?
A

No correct answer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Consider the following code fragment. Determine the valuesof members “x”and “y” for object “begin”

A

no correct answer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
consider the following code frament 
class A 
{int x;
Does the compiler reports by reference to the memeber function of class C?
A

Yes it is ambiguous reference

16
Q
consider the following code frament 
class A 
{int x;
How would you define a class member, which will have the same vluefor all objects of this class
A

As a static member

17
Q

Multiple inheritance is best decribed as?

A

A class derived from two or more base classes.

18
Q

Consider the following program fragment
class figure…
which handler is executed

A

THE PROGRAM IS WRONG

19
Q

Do the following catch block is correct?

catch (int) { ……throw;}

A

yes the same exception will be throw again.