0% found this document useful (0 votes)
15 views16 pages

Technical MCQs CTS

The document consists of a series of multiple-choice questions covering various programming languages including C, C++, Java, Python, and data structures. Each question presents a code snippet or concept and asks for the expected output or definition. The questions are designed to test knowledge and understanding of programming syntax, semantics, and data structures.

Uploaded by

mohammedimr29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views16 pages

Technical MCQs CTS

The document consists of a series of multiple-choice questions covering various programming languages including C, C++, Java, Python, and data structures. Each question presents a code snippet or concept and asks for the expected output or definition. The questions are designed to test knowledge and understanding of programming syntax, semantics, and data structures.

Uploaded by

mohammedimr29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

C Programming (Ch1)

1. Which of the following is not an arithmetic operation?

a) a * = 10;
b) a % = 10;
c) a ! = 10;
d) a / = 10;

Question 1 of 50

C Programming (Ch2)

2. What will be the output of the following C code?

#include <stdio.h>

void main()

int i = 0;

while (++i)

printf("H");

a) Varies
b) Compile time error
c) H is printed infinite times
d) H

C Programming (Ch3)

3. What is the advantage of #define over const?

 Data type is flexible

 None of the mentioned

 Reduction in the size of the program

 Can have a pointer

C Programming (Ch4)

4. What will be the output of the following C code?


#include <stdio.h>

int main()

const int ary[4] = {1, 2, 3, 4};

int *p;

p = ary + 3;

*p = 5;

printf("%d\n", ary[3]);

 4

 3

 Compile time error

 5

C Programming (Ch5)

5. Presence of code like “s.t.b = 10” indicates __________

 double data type

 Syntax Error

 An ordinary variable name

 Structure

C Programming (Ch6)

6. What is the default return-type of getchar()?

 char *

 int

 char

 reading character doesn't require a return-type

C Programming (Ch7)

7. Which of the following is not a valid mathematical function?

 fmod(x);
 srand(x);

 atan2(x,y);

 frexp(x);

C Programming (Ch8)

8. The ______ function appends not more than n characters.

 strcat()

 memcat()

 strncat()

 strcon()

C Programming (Ch9)

9. The assert macro returns__________value.

 double

 float

 no

 integer

C Programming (Ch10)

10. _______________ is the preprocessor directive which is used to end the scope of
#ifdef.

 #elif

 #if

 #endif

 #ifndef

C++ Programming (Ch1)

11. Which of the following is a static polymorphism mechanism?

 Templates

 Function overloading

 All of the mentioned

 Operator overloading
C++ Programming (Ch2)

12. What will be the output of the following C++ code?

#include <iostream>

using namespace std;

int add(int a, int b);

int main()

int i = 5, j = 6;

cout << add(i, j) << endl;

return 0;

int add(int a, int b )

int sum = a + b;

a = 7;

return a + b;

 11

 12

 13

 compile time error

C++ Programming (Ch3)

13. What will be the output of the following C++ code?

#include <iostream>

using namespace std;

namespace extra

int i;
}

void i()

using namespace extra;

int i;

i = 9;

cout << i;

int main()

enum letter { i, j};

class i { letter j; };

::i();

return 0;

 10

 9

 compile time error

 11

C++ Programming (Ch4)

14. When we are using heap operations what do we need to do to save the memory?

 add the objects

 both rename & delete the objects

 rename the objects

 delete the objects after processing

C++ Programming (Ch5)

15. What is the syntax of class template?

 template <paramaters> class declaration


 temp <paramaters> class declaration

 Template <paramaters> class declaration

 Temp <paramaters> class declaration

16. What is meant by exception specification?

 A catch can catch all types of exceptions

 A try can catch all types of exceptions

 A function can throw any type of exceptions

 A function is limited to throwing only a specified list of exceptions

17. What will be the output of the following C++ code?

#include <iostream>

#include <vector>

using namespace std;

int main()

vector<int> v;

for (int i = 1; i <= 5; i++)

v.push_back(i);

cout<<v.capacity()<<endl;

v.pop_back();

v.pop_back();

cout<<v.capacity()<<endl;

return 0;

 4

 4
4

 8

 8

18. What happens if a pair is not initialized?

 Both first and second part is initialized to zero or null

 Both first and second part is initialized a garbage value

 Second is initialized to zero or null and first is initialized a garbage value

 First is initialized to zero or null and second is initialized a garbage value

19. What does the size of the vector refers to in c++?

 Number of elements

 Type of vector

 Size of vector

 Name of vector

20. Which is used for formatting purpose in c++?

 &

 Whitespace

 Vector

 Container

Java Programming (Ch1)

21. What will be the output of the following Java code snippet?

double a = 0.02;

double b = 0.03;

double c = b - a;

System.out.println(c);

BigDecimal _a = new BigDecimal("0.02");


BigDecimal _b = new BigDecimal("0.03");

BigDecimal _c = b.subtract(_a);

System.out.println(_c);

 0.01

0.009999999999999998

 0.009999999999999998

0.009999999999999998

 0.01

0.01

 0.009999999999999998

0.01

22. What would be behaviour if the constructor has a return type?

 Compilation error

 Only String return type is allowed

 Compilation and runs successfully

 Runtime error

23. What will be the output of the following Java snippet, if attempted to compile
and execute?

class abc

public static void main(String args[])

if(args.length>0)

System.out.println(args.length);

 The snippet compiles, runs and prints 0

 The snippet does not compile


 The snippet compiles and runs but does not print anything

 The snippet compiles, runs and prints 1

24. Which of these packages contain all the Java's built in exceptions?

 java.util

 java.io

 java.net

 java.lang

25. Which of these method converts radians to degrees?

 convertRadian()

 toDegree()

 toRadian()

 converDegree()

26. What will be the output of the following Java program?

import java.util.*;

class Output

public static void main(String args[])

TreeSet t = new TreeSet();

t.add("3");

t.add("9");

t.add("1");

t.add("4");

t.add("8");

System.out.println(t);

}
 [1, 3, 5, 8, 9]

 [3, 4, 1, 8, 9]

 [9, 8, 4, 3, 1]

 [1, 3, 4, 8, 9]

27. Deadlock is a situation when thread is waiting for other thread to release
acquired object.

 True

 False

28. Which of these methods can be used to obtain the coordinates of a mouse?

 getMouseCordinates()

 getPoint()

 getMouseXY()

 getCoordinates()

29. What data structure should be used when number of elements is fixed?

 Vector

 Array

 Set

 Array list

30. Which of the below is not a valid classification of design pattern?

 Structural patterns

 Behavioural patterns

 Creational patterns

 Java patterns

Python:

31. What will be the output of the following Python code if a=10 and b =20?

a=10
b=20

a=a^b

b=a^b

a=a^b

print(a,b)

 20 20

 20 10

 10 10

 10 20

32. What will be the output of the following Python code?

d = {0: 'a', 1: 'b', 2: 'c'}

for x, y in d.items():

print(x, y)

 none of the mentioned

 0a 1b 2c

 abc

 012

33. What is the default value of encoding in encode()?

 utf-8

 utf-16

 qwerty

 ascii

34. What will be the output of the following Python code?

A = [[1, 2, 3],

[4, 5, 6],

[7, 8, 9]]

[[col + 10 for col in row] for row in A]


 [11, 12, 13, 14, 15, 16, 17, 18, 19]

 [11, 12, 13], [14, 15, 16], [17, 18, 19]

 [[11, 12, 13], [14, 15, 16], [17, 18, 19]]

 Error

35. What will be the output of the following Python code snippet?

>>>import collections

>>> b=collections.Counter([2,2,3,4,4,4])

>>> b.most_common(1)

 {4:3}

 [(4, 3)]

 Counter({4: 3, 2: 2, 3: 1})

 {3:1}

36. What will be the output of the following Python code?

lamb = lambda x: x ** 3

print(lamb(5))

 125

 555

 15

 None of the mentioned

37. In _______________ copy, the base address of the objects are copied. In
_______________ copy, the base address of the objects are not copied.

 shallow, deep

 deep. shallow

 memberwise, shallow

 deep, memberwise

38. What will be the output of the following Python code?


import turtle

t=turtle.Pen()

t.goto(300,9)

t.position()

 9.00, 300.00

 9, 300

 300, 9

 300.00, 9.00

39. What will be the output of the following Python code?

sentence = 'horses are fast'

regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')

matched = re.search(regex, sentence)

print(matched.group(2))

 ('horses', 'are', 'fast')

 'horses are fast'

 {'animal': 'horses', 'verb': 'are', 'adjective': 'fast'}

 'are'

40. What will be the output of the following Python code?

class A:

def __init__(self,x):

self.x = x

def count(self,x):

self.x = self.x+1

class B(A):

def __init__(self, y=0):

A.__init__(self, 3)

self.y = y

def count(self):
self.y += 1

def main():

obj = B()

obj.count()

print(obj.x, obj.y)

main()

 An exception in thrown

 31

 30

 01

Data Structures:

41. Consider the usual algorithm for determining whether a sequence of parentheses is
balanced. Suppose that you run the algorithm on a sequence that contains 2 left
parentheses and 3 right parentheses (in some order). The maximum number of
parentheses that appear on the stack AT ANY ONE TIME during the computation?

 4 or more

 3

 1

 2

42. Identify the infix expression from the list of options given below.

 +ab

 ab-c-

 a/b+(c-d)

 abc*+d+ab+cd+*ce-f-

43. LCP array and ______ is used to construct suffix tree.

 Suffix array

 Hash trie

 Hash tree

 Balanced tree
44. What are different ways of implementing free lists and which is simple among them?

 best fit, first fit, worst fit, simple-first fit

 best fit simple-best fit

 best fit, first fit, worst fit, simple-best fit

 best fit, first fit, worst fit, simple-worst fit

45. What is a complete binary tree?

 A binary tree, which is completely filled, with the possible exception of the bottom
level, which is filled from right to left

 Each node has exactly zero or two children

 A tree In which all nodes have degree 2

 A binary tree, which is completely filled, with the possible exception of the bottom
level, which is filled from left to right

46. Is tango tree represented as a tree of trees.

 False

 True

47. Which of the following is the simplest data structure that supports range searching?

 Heaps

 K-d trees

 AA-trees

 binary search trees

48. What will be the order of new heap created after union of heap H1 and H2 when
created by the following code.Initially both are of the order n.

FIB_UNION(H1,H2)

H =MAKE_HEAP()

min[H]= min[H1]

concatenate the root list of H2 with the root list of H

if (min[H1] = NIL) or (min[H2]!= NIL and min[H2] < min[H1])

then min[H] = min[H2]


n[H]= n[H1] + n[H2]

free the objects H1 and H2

return H

 n+n/2

 nlogn

 n+1

 2*n

49. Which of the following is a widely used form of the hash tree?

 Htree

 T tree

 B+ - tree

 Tiger tree hash

50. Given Adjacency matrices determine which of them are PseudoGraphs?


i) {{1,0} {0,1}}
ii) {{0,1}{1,0}}
iii) {{0,0,1}{0,1,0}{1,0,0}}

 i) ii) and iii)

 i) and iii)

 ii) and iii)

 only i)

You might also like