NEW
Font size
WorksheetsMOCK TEST-6(SET-A) MCA III Sem
Total questions: 58
Worksheet time: 29mins
A train 150 meters long passes a man walking at 6 km/h in the same direction in 30 seconds. Find the speed of the train in km/h.
36 km/h
42 km/h
46.8 km/h
50 km/h
If 12 men can complete a piece of work in 8 days, how many men will complete the same work in 6 days?
14
16
18
20
The average of 8 numbers is 20. If one number is removed, the average becomes 19. Find the removed number.
25
34
33
32
A sum of money becomes Rs. 800 in 2 years and Rs. 920 in 3 years at simple interest. Find the principal.
Rs. 666.67
Rs. 615.38
Rs. 640.00
Rs. 700.00
A shopkeeper allows a discount of 10% on the marked price and still gains 20%. Find the marked price if the cost price is Rs. 450.
Rs. 575
Rs. 600
Rs. 625
Rs. 650
If the ratio of two numbers is 3:5 and their sum is 64, find the numbers.
A. 18 and 46
B. 24 and 40
C. 20 and 44
D. 22 and 42
A and B together can do a piece of work in 12 days. A alone can do it in 18 days. In how many days can B alone complete it?
24 days
30 days
36 days
40 days
The speed of a boat in still water is 10 km/h, and the speed of the stream is 4 km/h. Find the time taken to travel 24 km downstream.
1.5 h
1.71 h
2 h
2.4 h
The sum of three consecutive even numbers is 84. Find the numbers.
24, 26, 28
26, 28, 30
28, 30, 32
22, 24, 26
A person covers 60 km at 20 km/h and another 60 km at 30 km/h. Find his average speed.
24 km/h
25 km/h
22.5 km/h
26 km/h
A can finish a work in 15 days and B in 20 days. They work together for 5 days. How much of the work is left?
1/3
5/12
7/12
2/5
The population of a town increases by 10% every year. If the present population is 10,000, what will it be after 2 years?
A. 11,000
B. 12,000
C. 12,100
D. 13,210
If selling price is double the cost price, find the profit percentage.
50%
100%
75%
200%
A sum of Rs. 5000 is borrowed at 10% compound interest per annum. Find the amount after 2 years.
Rs. 6000
Rs. 6050
Rs. 6100
Rs. 6150
Two pipes can fill a tank in 15 min and 20 min respectively. A third pipe can empty it in 30 min. How long will it take to fill the tank if all three pipes are opened together?
8 min
10 min
12 min
15 min
A card is drawn from a pack of 52 cards. Find the probability that it is a red king.
1/52
1/26
1/13
1/4
The difference between the simple and compound interest on Rs. 2500 for 2 years at 10% p.a. is Rs. 2.5. Verify the result.
True (Rs. 2.5)
False (Rs. 3.0)
False (Rs. 1.5)
False (Rs. 5.0)
If the cost of 12 pens is equal to that of 8 pencils, find the ratio of the cost of a pen to that of a pencil.
2:3
3:2
3:4
4:3
The area of a circle is 154 cm². Find its radius. (Take π = 22/7)
5 cm
6 cm
7 cm
8 cm
If 3A = 2B = 4C, find the ratio A : B : C.
4 : 6 : 3
3 : 4 : 2
2 : 3 : 4
6 : 4 : 3
What is the output of this code? public class Test1 { public static void main(String[] args) { try { System.out.println("Opening file..."); int result = 10 / 0; System.out.println("Reading file..."); } catch (ArithmeticException e) { System.out.println("Division by zero error"); } finally { System.out.println("Closing file..."); } } }
Opening file... Division by zero error Closing file...
Opening file... Reading file... Closing file...
Opening file... Division by zero error
Compilation error
What is the output of the following code? String s1 = "Java"; String s2 = new String("Java"); s2 = s2.intern(); System.out.println(s1 == s2);
true
false
Compilation error
NullPointerException
Predict the output of the following code: public class Test3 { public static void main(String[] args) { StringBuilder sb1 = new StringBuilder("Hello"); StringBuilder sb2 = new StringBuilder("Hello"); System.out.println(sb1.equals(sb2)); } }
true
false
Compilation error
ClassCastException
What is the output of the following code? public class Test4 { public static void main(String[] args) { String str = "hello world"; String[] parts = str.split(" "); System.out.println(parts.length); } }
A. 1
B. 2
C. 3
D. Compilation error
Which method can be used to get the length of an array in Java?
size()
length()
length
getSize()
What is the output of the following code? outer: for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 3; j++) { if (i == 2 && j == 2) break outer; System.out.print(i + "" + j + " "); } }
A. 11 12 13 21
B. 11 12 13 21 22
C. 11 12 13 21 22 23
D. 11 12 13
Which statement about threads in Java is correct?
Calling start() multiple times on the same thread object is allowed
run() method must be overridden in every Thread subclass
Two threads can access a synchronized method at the same time
Thread priorities range from 1 to 10
What is the output of the following code? class MyThread extends Thread { public void run() { System.out.print("Running "); } } public class ThreadTest1 { public static void main(String[] args) { MyThread t = new MyThread(); t.start(); System.out.print("Main "); } }
A. Running Main
B. Main Running
C. Output may vary due to thread scheduling
D. Compilation error
What is the output of the following code? public class Test5 { public static void main(String[] args) { int[] arr = new int[5]; System.out.println(arr[2]); } }
null
0
Compilation error
ArrayIndexOutOfBoundsException
What is the output of the following code? public class Test6 { public static void main(String[] args) { int x = 10; int y = ++x * x--; System.out.println(y); }}
A. 100
B. 110
C. 121
D. 90
31. The following function reverse() is supposed to reverse a singly linked list. There is one line missing at the end of the function.
/* Link list node */
struct node
{
int data;
struct node* next;
};
/* head_ref is a double pointer which points to head (or start) pointer
of linked list */
static void reverse(struct node** head_ref)
{
struct node* prev = NULL;
struct node* current = *head_ref;
struct node* next;
while (current != NULL)
{
next = current->next;
current->next = prev;
prev = current;
current = next;
}
/*MISSING STATEMENT HERE*/
}
a. Set the value of head_ref to prev;
b. Set the value of head_ref to current;
c. Set the value of head_ref to next;
d. Set the value of head_ref to NULL;
What is the output of following function in which start is pointing to the first node of the following linked list 1->2->3->4->5->6 ? void fun(struct node* start) { if(start == NULL) return; printf("%d ", start->data); if(start->next!= NULL ) fun(start->next->next); printf("%d ", start->data); }
a. 1 4 6 6 4 1
b. 1 3 5 1 3 5
c. 1 2 3 5
d. 1 3 5 5 3 1
The following C function takes a simply-linked list as input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some part of the code is left blank. Choose the correct alternative that contain the correct pseudocode for the blank line.
a. q = NULL; next of p = head; head = p;
b. next of q = NULL; head = p; next of p = head;
c. head = p; next of p = q; next of q = NULL;
d. next of q = NULL; next of p = head; head = p;
Suppose each set is represented as a linked list with elements in arbitrary order. Which of the operations among union, intersection, membership, cardinality will be the slowest?
union
membership
cardinality
union, intersection
Consider the function f defined below. struct item { int data; struct item * next; }; int f(struct item *p) { return ( (p == NULL) || (p->next == NULL) || ((p->data <= p->next->data) && f(p->next)) ); }
not all elements in the list have the same data value.
the elements in the list are sorted in non-decreasing order of data value
the elements in the list are sorted in non-increasing order of data value
None of them
A circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To which node should p point such that both the operations enQueue and deQueue can be performed in constant time?
rear node
front node
not possible with a single pointer
node next to front
Is it possible to create a doubly linked list using only one pointer with every node?
Not Possible
Yes, possible by storing XOR of addresses of previous and next nodes.
Yes, possible by storing XOR of current node and next node
Yes, possible by storing XOR of current node and previous node
Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?
Possible if X is not last node. Use following two steps (a) Copy the data of next of X to X. (b)Update the pointer of node X to the node after the next node. Delete next of X.
Possible if size of linked list is even.
Possible if size of linked list is odd
Possible if X is not first node. Use following two steps (a) Copy the data of next of X to X. (b) Delete next of X.
Which of the following is an application of XOR-linked lists?
Implementing stacks
Implementing queues
Memory-efficient linked list representation
Caching data structures
Consider the following function to traverse a linked list. void traverse(struct Node *head) { while (head->next != NULL) { printf("%d ", head->data); head = head->next; } } Which of the following is FALSE about above function?
The function may crash when the linked list is empty
The function doesn't print the last node when the linked list is not empty
The function is implemented incorrectly because it changes head
None of the above
In a doubly linked list, the number of pointers affected for an insertion operation will be
5
0
1
None of these
Consider an implementation of unsorted single linked list. Suppose it has its representation with a head and a tail pointer (i.e. pointers to the first and last nodes of the linked list). Given the representation, which of the following operation can not be implemented in O(1) time?
Insertion at the front of the linked list.
Insertion at the end of the linked list.
Deletion of the front node of the linked list.
Deletion of the last node of the linked list.
If every node u in G is adjacent to every other node v in G, A graph is said to be
a. Isolated
a. complete
a. finite
a. strongly connected
In a balance binary tree the height of two sub trees of every node can not differ by more than
2
1
3
In a Heap tree
Values in a node is greater than every value in left sub tree and smaller than right sub tree
Values in a node is greater than every value in children of it
Both of above conditions applies
None of above conditions applies
Breadth first search uses __________ as an auxiliary structure to hold nodes for future processing.
Stack
Linked list
Graph
Queue
Prims algorithm is based on ____________ method
Divide and conquer method
Dynamic programming
Greedy method
Branch and bound
The minimum number of interchanges needed to convert the array 89, 19, 40, 17, 12, 10, 2, 5, 7, 11, 6, 9, 70 into a heap with the maximum element at the root is
0
1
2
3
Which of the following is a valid heap ?
A 16 14 10 4 7 9 3 2 8 1
B 16 14 10 8 7 9 3 2 4 1
C 16 14 10 8 1 9 3 2 4 7
D 16 14 3 4 1 9 10 8 2 7
Given a disjoint-set forest with N elements, what is the maximum height of the trees in the forest after M union operations if union by rank and path compression techniques are used?
O(M)
O(logM)
O(N)
O(N + M)
Which of the following is not true?
Trie requires less storage space than hashing
Trie allows listing of all the words with same prefix
Tries are collision free
Trie is also known as prefix tree
The following code snippet is the function to insert a string in a trie. Find the missing line. void insert(char *str) { TrieNode *node = root; for (int i = 0; i < length; i++) { int index = str[i] - 'a'; if (node->children[index] == NULL) node->children[index] = (TrieNode *)malloc(sizeof(TrieNode)); } node->isEndOfWord = 1; }
node = node.children[index];
node = node.children[str.charAt(i + 1)];
node = node.children[index++];
node = node.children[index++];
Which data structure is used to perform level-order traversal on a binary tree?
Stack
Linked List
Queue
Hash Table
What is the minimum number of queues required for implementing a stack?
1
2
3
4
Which data structure is used to check a palindrome?
Linked List
Stack
Queue
Tree
What is the advantage of external hashing over open addressing?
Less space is used
Deletion operation is easier.
The time complexity is lesser
All of the above
What is the complexity of searching in direct addressing?
O(1)
O(log(n))
O(n)
What is the maximum depth of a tree with n strings of length m?
n
log₂ n
m
log₂ m
