.It is an instance of the class Select one: a. Method b. Object c. Data member d. Constructor   2.The encapsulation concept means. Select one: a. The class has private constructors and methods b. The data members are public access c. The data members are private access d. you can't access the members of the class even from the class itself   3.char A[]="hahahah"; char* p=&A[0]; *p='na'; p="CII"; cout<

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 6SA
icon
Related questions
Question

Question: Choose the correct one.

Note: Give me all the answers without explanation.

1.It is an instance of the class

Select one:
a. Method
b. Object
c. Data member
d. Constructor
 
2.The encapsulation concept means.
Select one:
a. The class has private constructors and methods
b. The data members are public access
c. The data members are private access
d. you can't access the members of the class even from the class itself
 
3.char A[]="hahahah"; char* p=&A[0]; *p='na'; p="CII"; cout<<A; the output is.
Select one:
a. CIIhahahah
b. hahahah
c. aahahah
d. nahahah
 
4.Let A is char array as follows: char A[]=”hahahah”; the length of A
Select one:
a. 32 characters
b. 7 characters
c. 28 characters
d. 8 characters
 
5.class A{int x;}; class B:public A{int y;public: void add(){y=++x;}};to correct the error.
Select one:
a. We should use protected: in class A
b. We should use private: in class A
c. We should use protected: in class B
d. We should use public: in class B
 
6.The class can have many destructors
Select one:
True
False
 
7.class A{int x; public:A(int x1){x=x1 ;}}; class B{A aa;}; we write in main: B b1; a syntax error occured because
Select one:
a. A has no default constructor
b. B has no default constructor
c. B has no public
d. B should have constructor with parameter
 
8.int *Arr[4]; int **p=Arr; int ptarr[3]={100,200,300}; int *pt1=new int[3]; Arr[0]=pt1; Arr[1]=ptarr; to set the first item in pt1 as the first item in ptarr
Select one:
a. *(*(p+0)+1)=*(*p+1)+1;
b. **p=*(*(p+1));
c. p[0][1]=p[1][0];
d. *(*(p+0)+0)=*(*p+1);
 
9.int B[5]={10,20,30,40,50}; int *p=&B[2]; to print the first item in B
Select one:
a. cout&lt;&lt;p-2;
b. cout&lt;&lt;*--p;
c. cout&lt;&lt;p[-2];
d. cout&lt;&lt;*((--p)--);
 
10.Where a protected member can be accessed?
Select one:
a. Within the same class only
b. Outside of the class
c. Within the same class and the derived class
d. Within the Derived class only
 
11.class A{int x; public:A(){ }}; we write in main: A a[5];
Select one:
a. 5 objects are created each one has value of x=0
b. Syntax error
c. 5 objects are created but each one has rubbish data for x
d. No objects are created
 
12.class A{int x;

public: 

A( ){x=0;}

void set(int x1){x=x1;}

int get(){return x;}

}a1(10)

Select one:
a. No syntax errors
b. It has syntax and logical errors
c. The code has one syntax error
d. The code has two syntax errors
 
13.class TV has one private integer data attribute and has one constructor with parameter. Which of the following is False?
Select one:
a. TV LG(100);
b. TV *p=new TV;
c. TV *p;
d. TV *p=0;
 
14.The name of the array is a pointer. It can point to any cell of the array
Select one:
True
False
 
15.int *Arr[4]; int **p=Arr; int *pt1=new int[3]; Arr[0]=pt1; to set the last element in array pt1 to -9
Select one:
a. **(p+2)=-9;
b. *(*p+2)=-9;
c. *(p++)[2]=-9;
d. *(p[2]-2)=-9;
 
16.int *Arr[4]; int **p=Arr; int ptarr[3]={100,200,300}; Arr[1]=ptarr; to add 1 to the second element in the array ptarr
Select one:
a. ++(*(p+1)[1]);
b. *(*(p+1))+=1;
c. ++*((*p+1)+1);
d. ++*(*(p+1)+1);
e. *(*(p+1)+1)=*(*p)+1;
 
17.The difference between the class and the struct is
Select one:
a. class data members by default are public while the struct are private
b. class data members by default are private while the struct are also private
c. class data members by default are public while the struct are also public
d. class data members by default are private while the struct are public
 
18.How many constructors can present in a class?
Select one:
a. 1
b. Multiple
c. 2
d. None
 
19.int B[5]={10,20,30,40,50}; int *p=&B[2]; to add 1 to the last item in B
Select one:
a. *(p+2)+=1;
b. *(p+2)++;
c. p[2]+1;
d. *B+2=51;
 
20.char *p="C++II"; the size of p
Select one:
a. 4 bytes
b. 5 bytes
c. 20 bytes
d. 6 bytes
 
21.Let B is an array of 5 integers as follows: int B[5]={10,20,30,40,50}; to define a pointer p points to item 20 in B
Select one:
a. int *p=B[1];
b. int *p=&amp;B[2];
c. int *p=B+1;
d. int *p=&amp;B+1;
 
22.class A is super of class B and B is super of class C, when we create C object the execution of constructors is
Select one:
a. A, B, C
b. C, A, B
c. C, B, A
d. A, C, B
 
23.Let A, B are two arrays of char, to check if A and B are matches
Select one:
a. if(strcmp(A,B)!=0) cout&lt;&lt;”Match”;
b. if(!strcmp(A,B) cout&lt;&lt;”Match”;
c. if(strcmp(A,B) cout&lt;&lt;”Match”;
d. if(strcmp(A,B)==1) cout&lt;&lt;”Match”;
 
24.The class A has a constructer with parameters and class B should have an object of the class A then
Select one:
a. The created object of class B must be with parameter
b. can't combine the two classes
c. class B should have default constructor
d. class A should have default constructor
 
25.class A{int x; public: A(int x1){x=x1;}A(){x=0;} }; class B{A aa; public: B(int x); }; the best way to implement the constructor of B
Select one:
a. B::B(int x){aa.x=x;}
b. B::B(int x){A a(x); aa=a;}
c. B::B(int x){A aa(x);}
d. B::B(int x){this-&gt;x=x;}
 
26.Assume int *Arr[4]; int **p=Arr; to let the last item in Arr points to "nothing"
Select one:
a. (*(*p+3))=0;
b. (*Arr[3])=0;
c. p+3=NULL;
d. Arr[3]=0;
 
 
 
 
 
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT