Está en la página 1de 6

Computer FUNDAMENTALS

Question 1
Which of the following statements is correct?
ABase class pointer cannot point to derived class.
BDerived class pointer cannot point to base class.
CPointer to derived class cannot be created.
DPointer to base class cannot be created.

Ans B

Question 2
How many types of polymorphisms are supported by C++?
A1
B2
C3
D4
Ans B

Question 3
What is the code below trying to print? void print(tree *root,tree *node) { if(root ==null) return 0
if(root–>left==node || root–>right==node || print(root->left,node)||printf(root->right,node) {
print(root->data) } }
A.just printing all nodes
B.not a valid logic to do any task
C.printing ancestors of a node passed as the argument
D.printing nodes from the leaf node to a node passed as the argument
Ans C

Question 4
Advantages of linked list representation of binary trees over arrays?
A)dynamic size
B)ease of insertion/deletion
C)ease in randomly accessing a node
D)both dynamic size and ease of insertion/deletion
Ans D

Question 5:

What will be the output of the program?

int main()
{
char ch;
ch = ‘A’;
printf(“The letter is”);
printf(“%c”, ch >= ‘A’ && ch <= 'Z' ? ch + 'a' - 'A':ch);
printf("Now the letter is");
printf("%c\n", ch >= ‘A’ && ch <= 'Z' ? ch : ch + 'a' - 'A');
return 0;
}

A.The letter is a Now the letter is A


B.The letter is A Now the letter is a
C.Error
D.None of above

Ans A

Question 6
Point out the error in the program?
int main()
{
int a[] = {10, 20, 30, 40, 50};
int j;
for(j=0; j<5; j++)
{
printf("%d\n", a); a++;
}
return 0;
}
A.Error: Declaration syntax
B.Error: Expression syntax
C.Error: LValue required
D.Error: Rvalue required

Ans C

Question 7
What will be the output of the program ?

void fun(int **p);


int main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
int *ptr;
ptr = &a[0][0];
fun(&ptr);
return 0;
}
void fun(int **p)
{
printf(“%d\n”, **p);
}
A.1
B.2
C.3
D.4
Ans A

Question 8:
Which of the following statements are correct about an array?
1: The array int num[26]; can store 26 elements.
2: The expression num[1] designates the very first element in the array.
3: It is necessary to initialize the array at the time of declaration.
4: The declaration num[SIZE] is allowed if SIZE is a macro.

A.1
B.1,4
C.2,3
D.2,4

AnsB

Question 9
Identify which of the following are declarations
1 : extern int x;
2 : float square ( float x ) { … }
3 : double pow(double, double);
A.1
B.2
C.3
D.1 & 3
Ans D

Question 10
Which of the following function is used to find the first occurrence of a given string in another string?
A.strchr()
B.strrchr()
C.strstr()
D.strnset()

Ans C

Question 11

Which of the following function declaration is/are incorrect?


A.int Sum(int a, int b = 2, int c = 3);
B.int Sum(int a = 5, int b);
C.int Sum(int a = 0, int b, int c = 3);
D.Both B and C are incorrect.
E.All are correct.

Ans C

Question 12
Which of the following statement is incorrect?
A.The default value for an argument can be a global constant.
B.The default arguments are given in the function prototype.
C.The compiler uses the prototype information to build a call, not the function definition.
D.The default arguments are given in the function prototype and should be repeated in the function
definition.

Ans D

Question 13
What will be the output of the following program?
typedef void(*FunPtr)(int);
int Look(int = 10, int = 20);
void Note(int);
int main()
{
FunPtr ptr = Note;
(*ptr)(30);
return 0;
}
int Look(int x, int y)
{
return(x + y % 20);
}
void Note(int x) {
cout<< Look(x) << endl;
}
A.10
B.20
C.30
D.40
E.Compilation fails

Ans C

Question 14:
What will be the output of the following program?

int main()
{
float Amount;
float Calculate(float P = 5.0, int N = 2, float R = 2.0);
Amount = Calculate();
cout<< Amount << endl;
return 0;
}
float Calculate(float P, int N, float R)
{
int Year = 1;
float Sum = 1 ;
Sum = Sum * (1 + P * ++N * R);
Year = (int)(Year + Sum);
return Year;
}
A.21
B.22
C.31
D.32
E.None of these

Ans D

Question 15:
What will be the output of the following program
class BaseCounter {
protected: long int count;
public: void CountIt(int x, int y = 10, int z = 20) {
count = 0;
cout<< x << " " << y << " " << z << endl;
}
BaseCounter()
{
count = 0;
}
BaseCounter(int x)
{
count = x ;
}
};
class DerivedCounter: public BaseCounter {
public: DerivedCounter()
{
}
DerivedCounter(int x): BaseCounter(x)
{
}
};
int main()
{
DerivedCounter objDC(30);
objDC.CountIt(40, 50);
return 0;
}

A.30 10 20
B.Garbage 10 20
C.40 50 20
D.20 40 50
E.40 Garbage Garbage

También podría gustarte