Sie sind auf Seite 1von 14

Academic Year 2016-17 (Sem II)

Subject: PPL Unit II : Computing the Data, Computation

Qno. QUESTION ANSWER

Which of the following is true about the characteristics of abstract data types?

i) It exports a type.

ii) It exports a set of operations

A) True, False

B) False, True

C) True, True

D) False, False
1 c
Which of the following is not the part of ADT description?

A) Data

B) Operations

C) Both of the above

D) None of the above


2 d

Data types are differed on basis of


A. way of storage.
B. type of operations.
C. type of operators used.
3 D. both a and b. d

When variable used in program is whole number, variable is stored as


A. fixed string.
B. integers.
C. negative whole numbers.
D. positive whole numbers.
4 b
int main()
{
int a[5] = {1, 2, 3, 4, 5};
int i;
for (i = 0; i < 5; i++)
if ((char)a[i] == '5')
printf("%d\n", a[i]);
else
printf("FAIL\n");
}
A. The compiler will flag an error
B. Program will compile and print the output 5
C. Program will compile and print the ASCII value of 5
D. Program will compile and print FAIL for 5 times
5 d

Which of the following is a User-defined data type?


A. typedef int Boolean;
B. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
C. struct {char name[10], int age};
D. All of the mentioned
6 d

What is the size of an int data type?


A. 4 Bytes
B. 8 Bytes
C. Depends on the system/compiler
D. Cannot be determined
7 c

If an expression contains double, int, float, long, then whole expression will
promoted into which of these data types?
a) long
b) int
c) double
d) float
8 c

Continue statement is used .............

A) to go to the next iteration in a loop

B) come out of a loop

C) exit and return to the main function

D) restarts iteration from beginning of loop


9 a

In C/CPP programming a function can return


A) Single value
B) Double values
C) Many values
10 D) None of these a
In C/CPP programming array index is always starts with
A) 0
B) 1
C) 2
D) 3
11 a

While coding in C/CPP programming for “call by reference” we pass


A) Address of variable
B) Value of variable
C) Either value or address
D) Both value or address
12 a

The most appropriate matching for the following pairs


X: Indirect addressing 1: Loops
Y: Immediate addressing 2: Pointers
Z: Auto decrement addressing 3. Constants
is
(a) X—3 Y—2 Z—1
(b) X—1 Y—3 Z—2
(c) X—2 Y—3 Z—1
(d) X—3 Y—1 Z—2
13 c

Aliasing in the context of programming languages refers to


(a) multiple variables having the same memory location
(b) multiple variables having the same value
(c) multiple variables having the same identifier
(d) multiple uses of the same variable
14 a

What is printed by the print statements in the program P1 assuming call by


reference parameter passing?
Program Pl()
{
x=10;
y=3;
func1(y, x, x);
print x;
print y;
}
func1 (x, y, z)
{
y = y + 4;
z = x + y + z;
}
a) 10, 3
b) 31, 3
c) 27, 7
15 d) None of the above b
1. Which of the following is the functionality of ‘Data Abstraction’?
a) Reduce Complexity
b) Binds together code and data
c) Parallelism
d) None of the mentioned
16 a

Which of the following mechanisms is/are provided by Object Oriented


Language to implement Object Oriented Model?
a) Encapsulation
b) Inheritance
c) Polymorphism
17 d) All of the mentioned d

Which of the following mechanisms is/are provided by Object Oriented


Language to implement Object Oriented Model?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) All of the mentioned
18 d

Which of the these is the functionality of ‘Encapsulation’?


a) Binds together code and data
b) Using single interface for general class of actions.
c) Reduce Complexity
19 d) All of the mentioned a

What is ‘Basis of Encapsulation’?


a) object
b) class
c) method
20 d) all of the mentioned d

How will a class protect the code inside it?


a) Using Access specifiers
b) Abstraction
c) Use of Inheritance
21 d) All of the mentioned a

Which of the following is a mechanism by which object acquires the


properties of another object?
a) Encapsulation
b) Abstraction
c) Inheritance
22 d) Polymorphism c

Which of the following concept is often expressed by the phrase, ‘One


interface, multiple methods’?
a) Abstraction
b) Polymorphism
c) Inheritance
23 d) Encapsulation b
16-bit compiler allowable range for integer constants is ________?
A. -3.4e38 to 3.4e38
B. -32767 to 32768
C. -32668 to 32667
24 D. -32768 to 32767 d

Which one of the following is not a reserved keyword for C?


A. auto
B. case
C. main
D. default
25 E. register c

C variable cannot start with


A). A number
B). A special symbol other than underscore
C). Both of the above
26 D). An alphabet c

Which one of the following is not a valid identifier?


A. _examveda
B. 1examveda
C. exam_veda
27 D. examveda1 b

Which is the only function all C programs must contain?


A. start()
B. system()
C. main()
D. printf()
28 E. getch() c

What number would be shown on the screen after the following statements of
C are executed?
char ch;
int i;
ch = 'G';
i = ch-'A';
printf("%d", i);
A. 5
B. 6
C. 7
D. 8
E. 9
29 b

Which of following is not a valid name for a C variable?


A. Examveda
B. Exam_veda
C. Exam veda
D. Both A and B
E. None of these
30 c
Identify the built in data type
a) Struct
b) Class
c) Int
31 d) Enum c

Identify the user defined data type


a) Struct
b) Class
c) Enum
32 d) All of these d

The value 789.45 can be represented using ______________data type


a) Int
b) Char
c) Double
33 d) Struct c

The structures data types that are built in Pascal are ________________
a) Arrays and records
b) Variant records
c) Sets and files
d) All of these
34 a

Is bool fundamental data type in C++?


a) Yes
b) No it is expanded from macro
c) No it is obtained using typedef
d) No it is obtained using enum
35 a

Which data type have size that is varying?


a) Int
b) Float
c) Double
36 d) Struct d

# include<iostream>
using namespace std;
int main()
{
float a=’a’;
cout<<a;
return 0;
}
a) a
b) 0.0
c) 97.0000000
37 d) syntax error c
# include<iostream>
using namespace std;
enum test
{
x=10,y,z,w
};
int main()
{
cout<<x<<” “<<y<<” “<<z<<” “<<w;
return 0;
}
a) 10 11 12 9
b) 10 11 12 13
c) Syntax error
d) 10 garbage garbage garbage
38 b

___________has equal size as that of enum variable


a) Int variable
b) Float variable
c) String variable
39 d) None of these a

What will be the output of the following code>


int main( )
{
char ch;
ch = 130;
printf(“%d\n”,ch);
return 0;
}
a) 130
b) -130
c) -126
d) Syntax error
40 c

What will be the output of the following code?


# include<iostream>
using namespace std;
int main()
{
int x=4;
int a=x/-3;
int b=x%-3;
cout<<a<<” “<<b;
return 0;
}
a) 1 -1
b) -1 1
c) 0 0
41 d) Syntax error b
Explicit type conversion is known as_______________
a) Conversion
b) Casting
c) Separation
42 d) None of these b

The type system in which the programming language contains the variables
that may belong to more than one type is called
_________________________
a) Monomorphic type system
b) Polymorphic type system
c) One variable with multiple data types is an impossible thing
43 d) None of these b

The type system in which the programming language contains the variables
that belong to one type is called _________________________
a) Monomorphic type system
b) Polymorphic type system
c) One variable with multiple data types is an impossible thing
44 d) None of these a

Choose the correct statement


Using a template
a) The function is written only once and it will be used for different types.
b) It will take long time to execute
c) Duplicate code gets increased
d) None of these
45 a

Type system is basically


a) Collection of rules to be followed to define and manipulate program data
b) Collection of various primitive data types
c) Collection of various user defined data types
46 d) None of these a

What is strong type system?


a) The type system in which only built-in data types are allowed
b) The type system in which only user defined data types are allowed
c) The type system that guarantees not to generate type errors
47 d) None of these c

For representing logical values ______________________ data type is used


in c++
a)int
b) bool
c) char
48 d) none of these b)

It is necessary to have _______________________ at the time of array


initialization.
a) Row
b) Column
c) Both a and b
49 d) None of these a)
Looping in a program means
a) Jumping to the specified branch of a program
b) Repeat the specified lines of code
c) Both of the above
50 d) None of these b)

Which of the following is not a looping statement in C?


a) While
b) Until
c) Do
51 d) For b)

Which of the following is a selection statement in C++?


a) Goto
b) Exit
c) Switch
52 d) Break c)

Which of the following is not a jump statement in C++?


a) Goto
b) Exit
c) Switch
53 d) Break c)

Which of the following statement creates infinite loop?


a) for(; ;)
b) if(; ;)
c) while(; ;)
54 d) when (; ;) a)

The use of a break statement is


a) to terminate a case in switch statement
b) to terminate the loop immediately’
c) both a and b
55 none of these c)

What will be the output of the following code?\


int main()
{
int i;
for(i=0;i<10;i++);
cout<<i<<” “;
return 0;
}
a) 10
b) 0 1 2 3 4 5 6 7 8 9
c) 012345678910
56 d) Syntax error a)
What will be the output of the following code
Consider the following statements
int x=20, y=30;
x = (x>y) ? (x+y) : (x-y);
a) 10
b) 50
c) -10
57 d) Error c)

What will be the output of the following code


Consider the following statements
int x=20, y=30;
x = (x<y) ? (x+y) : (x-y);
a) 10
b) 50
c) -10
58 d) Error b)

What is the task of continue inside a loop?


a) It cancels remaining iterations
b) It skips particular iteration
c) The program terminates immediately
59 d) Loop counter is reset b)

What is the task of break inside a loop?


a) It cancels remaining iterations
b) It skips particular iteration
c) The program terminates immediately
60 d) Loop counter is reset. a)

Most of the programming language support following type of routine


a) Function
b) Procedure
c) Both a and b
61 d) None of these c)

Pascal supports following type of


routine______________________________
a) Only procedures
b) Only functions
c) Both procedures and functions
62 d) Neither procedure nor function is allowed in pascal c)

Choose the correct statement


I. Procedure is a kind of routine that returns a value
II. Function is a kind of routine that does not return a value.
a) Only I
b) Only II
c) Both I and II
63 d) Neither I nor II d)
I. Procedure is a kind of routine that does not return a value
II. Function is a kind of routine that does not return a value.
a) Only I
b) Only II
c) Both I and II
64 d) Neither I nor II a)

Exception handling is for__________________________


a) Handling runtime error
b) Handling syntax error
c) Handling logical error
65 d) All of these a)

Exception occurs due to


a) Operating system problem
b) Hardware problem
c) Syntax error
66 d) Runtime error d)

The code of statements that can cause abnormal termination of the program
should be written in ___________
a) Try block
b) Catch block
c) Catch all block
67 d) Finally block a)

Which keyword is used to send error information to catch block?


a) Throw
b) Try
c) Catch
d) Exception
68 a)

Exception handlers are declared with ___________keyword


a) Try
b) Catch
c) Finally
d) None of these
69 b)

Exception is thrown using the keyword _______________


a) Throw
b) Throws
c) Thrown
d) Throwing
70 a)
What is the output of the following code?
void division(const double a, const double b)
{
double ans;
if(b==0)
throw “error! Division by zero”
ans = a/b;
cout<<ans;
}
int main()
{
double op1=0,op2=20;
try
{
Division(op1,op2);
}
catch(const char *str)
{
cout<<str;
}
return 0;
}
a) 0
b) 1
c) Error! Division by zero
71 d) Syntax error a)
What is the output of the following code?
void division(const double a, const double b)
{
double ans;
if(b==0)
throw “error! Division by zero”
ans = a/b;
cout<<ans;
}
int main()
{
double op1=0,op2=20;
try
{
Division(op2,op1);
}
catch(const char *str)
{
cout<<str;
}
return 0;
}
a) 0
b) 1
c) Error! Division by zero
d) Syntax error
72 c)

What will happen when a program throws any other type of exception other
than specified?
a) Program will crash
b) Arise an error
c) Program will still execute
d) None of these
73 b)

Which is the valid catch statement ?


a) catch() {//function body}
b) catch(...) {//function body}
c) catch(class_name) {//function body}
d) none of these
74 b)

What happens if several handlers match the type of the thrown object?
a) All handlers will be executed and the messages will be displayed
b) Program will crash
c) The first matching exception handler after the try block is executed
d) None of these
75 c)
Choose the correct statement
I. The catch must be placed immediately after try block T.
II. There must be only one catch handler for every try block
III. There can be multiple catch handler for a try block T.
IV. It can have multiple parameters
a) Only I
b) All of these
c) I and II
d) I and III
76 d)

How Many parameters does the throw expression can have?


a) 1
b) 2
c) 3
d) 4
77 a)
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

Das könnte Ihnen auch gefallen