0% found this document useful (0 votes)
34 views

AMCAT-Programming Ability -IV

The document consists of a series of programming questions and their correct answers, covering topics such as data structures, algorithms, and programming concepts. Each question is presented with multiple-choice options, and the correct answer is indicated for each. The questions range from basic programming logic to more complex concepts in computer science.

Uploaded by

Tarun Rohan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

AMCAT-Programming Ability -IV

The document consists of a series of programming questions and their correct answers, covering topics such as data structures, algorithms, and programming concepts. Each question is presented with multiple-choice options, and the correct answer is indicated for each. The questions range from basic programming logic to more complex concepts in computer science.

Uploaded by

Tarun Rohan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Question 1 A 10-bit unsigned integer has the following range:

Not answered
Select one:
Marked out of
1.00 a. 0 to 1025

b. 0 to 1024

c. 0 to 1000

d. 0 to 1023

The correct answer is: 0 to 1023

Question 2 Choose the correct answer


Not answered Abhinav wants to find the largest number in a given list of 20 numbers.
Marked out of Which of the following is an efficient approach to do this?
1.00

Select one:
a. Implement one iteration of selection sort for descending order and
print the first number in the series.

b. Beginning from a node, each adjacent node is fully explored before


traversing the next adjacent node.

c. None of these

d. Use bubble sort to sort the list in descending order and then print the
first number of the series.

The correct answer is: Implement one iteration of selection sort for
descending order and print the first number in the series.
8/21/2019 AMCAT-Programming Ability -IV
Question 3 In breadth-first search, which of the following is true?
Not answered
Select one:
Marked out of
1.00 a. None of these

b. Beginning from a node, nodes are traversed in cyclical order

c. Beginning from a node, first all its adjacent nodes are traversed.

d. Beginning from a node, each adjacent node is fully explored before


traversing the next adjacent node.

The correct answer is: Beginning from a node, first all its adjacent nodes are traversed.

Question 4 A constructor is called whenever:


Not answered
Select one:
Marked out of
1.00 a. An object is declared

b. An object is deleted

c. A class is deleted

d. A class is declared

The correct answer is: An object is declared

Question 5 Which of these refer to data-hiding in Object Oriented


Not answered
Programming? Select one:
Marked out of
1.00 a. A class does not have functions as private members.

b. A single class can have many objects.

c. A class has both data and functions on the data in the class.

d. Data in private and protected area of a class is not directly accessible


and can only be accessed through member functions in the public area of
class.

The correct answer is: Data in private and protected area of a class is not
directly accessible and can only be accessed through member functions in the
public area of class.
8/21/2019 AMCAT-Programming Ability -IV
Question 6 For a path to be Eulerian, which of the following conditions are necessary and
Not answered
sufficient?

Marked out of
1.00 Select one:
a. The graph should have even edges.

b. The graph should have odd edges.

c. Degree of each vertex in the graph should be odd.

d. Degree of each vertex in the graph should be even.

The correct answer is: Degree of each vertex in the graph should be even.

Question 7 What are the maximum number of edges in a n-vertex


Not answered
undirected graph? Select one:
Marked out of
1.00 a. n*(n-1)/2

b. 2*n

c. n*n

d. n*(n+1)/2

The correct answer is: n*(n-1)/2

Question 8 Lavanya wants to find the smallest number out of 26 inputted numbers.
Not answered How many minimum comparisons he has to make?

Marked out of
1.00 Select one:
a. 52

b. 13

c. 41

d. 25

The correct answer is: 25


8/21/2019 AMCAT-Programming Ability -IV
Question 9 The for loop is equivalent to a while loop when
Not answered
Select one:
Marked out of
1.00 a. There is no increment expression

b. It is never equivalent

c. There is no initialization expression

d. A and B combined are true

The correct answer is: A and B combined are true

Question 10 What is implied by the argument of a


Not answered
function? Select one:
Marked out of
1.00 a. Its return type

b. The variables passed to it when it is called

c. he value it returns on execution

d. The execution code inside it

The correct answer is: The variables passed to it when it is called


8/21/2019 AMCAT-Programming Ability -IV
Question 11 A stack is implemented as a linear array A[0. N1]. Giri writes the following functions
Not answered
for
popping an element from the
Marked out of
1.00 stack. function POP(top,N)
{
if(X)
{
top=top‐1
}
else
{
print "Underflow”
}
return top
}
Fill in the
condition X Select
one:
a. top>1
b. top< N1
c. top >= 0
d. top

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: c
8/21/2019 AMCAT-Programming Ability -IV
Question 12 What will be the output of the following pseudocode statement?
Not answered Integer a= 456, b, c,
Marked out of d=10 b = a /d
1.00
c = a‐b
print c
Select
one:
a. 411.4
b. 411
c. 410
d. 410.4

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: b
8/21/2019 AMCAT-Programming Ability -IV
Question 13 Seema writes the code for a function that takes as input n, and even integer
Not answered and calculates the sum of first n even natural numbers

Marked out of Function sum(n)


1.00
{
if(n equals 2)
return
2 else
return (n+sum(n‐
2)) end
}
She then calls the function by the statement, sum(30). How many times will
the function sum be called to compute the sum?
Select one:
a. 1
b. 30
c. 16
d. 15

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: d
8/21/2019 AMCAT-Programming Ability -IV
Question 14 Ashima wants to print a pattern which includes checking and changing a
Not answered variable’s value iteratively. She decides to use a loop/condition. Which of the
following options should she use such that the body of the loop/condition is
Marked out of
1.00 executed at least once whether the variable satisfies the entering condition or
not?
Select one:
a. Do While Loop
b. Switch Case
c. For Loop
d. While Loop

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: a

Question 15 In breadthfirst search, which of the following option


Not answered
is true? Select one:
Marked out of a. Beginning from a node, first all its adjacent nodes are traversed.
1.00
b. Beginning from a node, nodes are traversed in cyclical order
c. Beginning from a node, each adjacent node is fully explored before
traversing the next adjacent node.
d. None of these

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: a
8/21/2019 AMCAT-Programming Ability -IV
Question 16 Tanuj writes the code for a function that takes as input n and calculates the
Not answered sum of first n natural numbers

Marked out of Function sum (n)


1.00
{
if(??)
Return
1 Else
Return (n+sum(n‐
1)) End
}
Fill ?? in the
code Select
one:
a. n > 1
b. n equals 2
c. n equals 1
d. n > = 1

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: c
8/21/2019 AMCAT-Programming Ability -IV
Question 17 Consider a Binary tree implementation. The root address is stored in the
Not answered variable root. Given the address of a node in variable node, its value, right
and root child node address can be accessed using the following statements
Marked out of
1.00 respectively: node> value, node> right, node> left. Sameer writes the
following function to do a preorder traversal of the tree
function preordertraverse(node)
{
print node‐
>value
if(Condition X)
{
preordertraverse(node‐>left)
}
if (Condition Y)
{
preordertraverse(node‐>right)
}
return 0;
}
What is condition X and
condition Y? Select one:
a. Condition X: node > left is equal null Condition Y: node > right is equal null
b. Condition X: node > right is equal null Condition Y: node > left is equal null
c. Condition X: node > left is not equal null Condition Y: node > right is not equal null
d. Condition X: node > right is not equal null Condition Y: node > left is not equal null

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: a
8/21/2019 AMCAT-Programming Ability -IV
Question 18 Following program is to print the sum of all cubes, where the value of the cubes
Not answered go from 0 to 100.

Marked out of integer i=0, a


1.00
//statement 1 integer
sum=0;
a=(i*i*i)
while (i<100) // statement 2
{
sum = sum + a //
statement 3 i=i+1
a=(i*i*i) // Statement 4
}
print sum
Does the program have and error? If yes, which statement would you modify to
correct the program?
Select one:
a. Statement 3
b. No Error
c. Statement 2
d. Statement 4

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: c
8/21/2019 AMCAT-Programming Ability -IV
Question 19 What will the Prefix equivalent for the given notation – (M+N)
Not answered
(O+P*Q)/R*S Select one:
Marked out of a. /+MN*+OPQ*RS
1.00
b. +MN*/+O*PQRS
c. +MN*/+OPQ*RS
d. /+MN*+O*PQRS

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: b
8/21/2019 AMCAT-Programming Ability -IV
Question 20 integer
Not answered
i=0, j while
Marked out of (i<2)
1.00
{j
=0
;
while (j<=3*i)
{
print j
print blank
space j=j+3
}
print end of the line // takes cursor to
next line i=i+1
}
What is the
output? Select
one:
a. 0 3
036
0369
b. 0 3
03
6
c. 0 3
03
6
0369
0 3 6 9 12
d. 0
0
3

Select one:
a. a

b. b

c. c
d. d

Your answer is
incorrect. The correct
answer is: d
8/21/2019 AMCAT-Programming Ability -IV
Question 21 What will be the output of the following pseudo code
Not answered
statements Integer a = 984, b=10
Marked out of Float
1.00
c
c=a/b
Print
c
Select one:
a. 98.0
b. 98.4
c. 984
d. Error

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: a
8/21/2019 AMCAT-Programming Ability -IV
Question 22 Sharma writes a piece of code, where a set of three lines occur around ten times
Not answered in different parts of the program. What programming concept can he use to
shorten his program code length?
Marked out of
1.00 Select one:
a. Use for loops
b. Use classes
c. Use arrays
d. Use functions

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: d

Question 23 Which of the following options describes a


Not answered
tree? Select one:
Marked out of a. An unconnected graph
1.00
b. A complete graph
c. A connected graph
d. A connected acyclic graph

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: d
8/21/2019 AMCAT-Programming Ability
Question 24 Which of the following items may or may not have its methods
Not answered
implementations? Select one:
Marked out of a. Generic class
1.00
b. Abstract class
c. Anonymous class
d. Interface

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: b

Question 25 A queue is implemented as a single linked list. Each node has an element and
Not answered pointer to another node. Rear and Front contain the addresses of rear and front
node respectively. If the condition (rear is equal front) is true and neither is
Marked out of
1.00 NULL, What do we infer about the linked list?
Select one:
a. There is an error
b. It has one element
c. It has no elements
d. None

Select one:
a. a

b. b

c. c

d. d

Your answer is
incorrect. The correct
answer is: b

You might also like