Thursday, July 29, 2010

C Question Set 1-1

Question1
The phenomenon where the object outlives the program execution time and exists between executions of a program is known as.

Global Object
Persistent Object
Genericity
Delegation

Question 2
Object-Based Programming Language supports

Inheritance
Polymorphism
Encapsulation
All of the above

Question 3
Abstraction is crucial to understanding

Class
Application
Object
Control flow

Question 4
Object oriented design decomposes a system into

Classes
Objects
Structures
Methods

Question 5
If a class member function is declared a const, the function

Does not change the value of any data member of that class
Does not change the value of any data member of implied object
Does not change the value of any data member of that class
All of the above

Question 6
What is the output of the program?

#include <stdio.h>
float cal (float value)
{
return (3 * value);
}
void main()
{
int a = 10;
float b = cal ("123");
}
369
123
Compilation error - Cannot convert from char to float
None of the above
Question 7
The act of grouping into a single object, both data and the operation that affect that data is known as

Encapsulation
Inheritance
Abstraction
None of the above

Question 8
What is a class?

It is a region of storage.
It defines a data type.
It is exactly same as a struct in c.
All of the above.

Question 9
What is the output of the program?
#include <iostream.h>
void main ()
{
for(int j = 1, sum = 0; j < 5; j++)
sum += j;
sum = j;
cout << sum;
}
5
10
Compilation error. Undefined variable sum and j
6

Question 10
Which one supports unknown data types in a single framework?

Inheritance
Virtual functions
Templates
Abstract Base Class

Question 11
Inheritance is expressed by the following statement?

class car : public vehicle
class car extends vehicle
public class car extends vehicle
class car inherits vehicle

Question 12
Object oriented design decomposes a system into
Classes
Objects
Structures
Methods
Question 13
Which of the following statements is not correct?

You can create new operators like $ or @
You cannot change an operator's template
Operators can only be overloaded when used with abstract data class
Unary operators overloaded by means of a member functions takes no explicit arguments and return no explicit values

Question 14
Which of the following is false about struct and class in C++?

The members and base classes of a struct are public by default, while in class, they are private by default
Struct and class are otherwise functionally equivalent
A class supports all the access specifiers like private, protected and public
A struct cannot have protected access specifier

Question 15
Protected keyword is frequently used

For function overloading
For protecting data
For inheritance
For security purpose

Question 16
Abstract base class is one, which has

All pure virtual functions
At least one pure virtual function
Functions with abstract keyword
No pure virtual functions
Question 17
What is exception handling?

Errors which occur at runtime
When abnormal situation arises at compile time
When errors occur at link time
None of the above

Question 18
What is the output of the program?
#include <iostream.h>
inline int max(int x, int y)
{
return(x > y ? x : y);
}
void main()
{
int(* max_func)(int,int)=max;
cout << max_func(75,33);
}
75
Error - Undefined symbol max_func
33
None of the above

Question 19
Which keyword is used to decide on the choice of function or method at runtime?
Abstract
Virtual
Protected
Static

Question 20
Which of the following is a correct statement?

Abstract class object can be created
Pointer to abstract class can be created
Reference to abstract class can be created
Both B and C

Answers
Answer 1 - B
Answer 2 - C
Answer 3 - C
Answer 4 - B
Answer 5 - B
Answer 6 - C
Answer 7 - A
Answer 8 - B
Answer 9 - A
Answer 10 - C
Answer 11 - A
Answer 12 - B
Answer 13 - A
Answer 14 - D
Answer 15 - C
Answer 16 - B
Answer 17 - A
Answer 18 - A
Answer 19 - B
Answer 20 - D

No comments:

Post a Comment