1 ST 2 ND Ans

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

1.

Data structures are:

 a) Sets of values

 b) Sets of associations or relationships involving elements

 c) Methods for storing data

 d) Programming languages
Answer: b) Sets of associations or relationships involving elements

2. The stackTop() operation in a stack ADT:

 a) Adds an element to the stack

 b) Removes the topmost element

 c) Returns the topmost element

 d) Returns the number of elements


Answer: c) Returns the topmost element

3. The stack is empty if:

 a) stackTop() returns null

 b) isEmpty() returns false

 c) isEmpty() returns true

 d) No isEmpty() method is called


Answer: c) isEmpty() returns true

4. The POP operation:

 a) Removes the element currently pointed to by top

 b) Inserts an element into the stack

 c) Returns the topmost element without removing it

 d) Does nothing if the stack is full


Answer: a) Removes the element currently pointed to by top

5. The PUSH operation:

 a) Removes the topmost element


 b) Inserts an element at the bottom

 c) Inserts an element on top of the most recently inserted element

 d) Inserts an element into the middle


Answer: c) Inserts an element on top of the most recently inserted element

6. What happens during stack overflow?

 a) Too many POP operations are performed

 b) A PUSH operation is called on a full stack

 c) The stack is cleared

 d) The stack becomes empty


Answer: b) A PUSH operation is called on a full stack

7. Data encapsulation refers to:

 a) Only storing data in variables

 b) Writing code without comments

 c) Packaging data values together with the operations on those values

 d) Separating data from operations


Answer: c) Packaging data values together with the operations on those values

8. If the water level of a water tank is equal to 0, the isEmpty() method will:

 a) Return true

 b) Return false

 c) Throw an error

 d) Do nothing
Answer: a) Return true

9. In a water tank ADT, addWater() is classified as:

 a) An observer operation

 b) A destructor

 c) A creator
 d) A transformer
Answer: d) A transformer

10. The ~waterTank() operation in a water tank ADT is:

 a) A destructor

 b) A creator

 c) An observer

 d) A transformer
Answer: a) A destructor

11. If PUSH is called on a non-empty and non-full stack:

 a) A new item becomes the last element

 b) The stack overflows

 c) The stack underflows

 d) The bottom-most element is removed


Answer: a) A new item becomes the last element

12. After a POP operation on a stack, what happens to the topmost item?

 a) It stays at the top

 b) It becomes the bottom element

 c) The next oldest item becomes the topmost

 d) The stack becomes empty


Answer: c) The next oldest item becomes the topmost

13. Abstract data types (ADT) focus on:

 a) The how rather than the what

 b) The implementation details

 c) The what rather than the how

 d) None of the above


Answer: c) The what rather than the how
14. A stack implements:

 a) First-in, First-out (FIFO)

 b) Last-in, First-out (LIFO)

 c) Circular structure

 d) Sequential processing
Answer: b) Last-in, First-out (LIFO)

15. What happens if POP is called on a full stack?

 a) The topmost element is deleted

 b) The stack overflows

 c) The bottom-most element is removed

 d) Nothing happens
Answer: a) The topmost element is deleted

16. What happens if POP is called on an empty stack?

 a) The topmost element is deleted

 b) The stack underflows

 c) The stack overflows

 d) A new element is added


Answer: b) The stack underflows

17. Which operations are involved in an ADT?

 a) Creators, transformers, observers, input/output

 b) Only creators and observers

 c) Only observers and transformers

 d) None of the above


Answer: a) Creators, transformers, observers, input/output

18. What kind of data structures are general and binary trees?
 a) Linear data structures

 b) Hierarchical data structures

 c) Circular data structures

 d) Unstructured data
Answer: b) Hierarchical data structures

19. A tree is said to be a general tree if it has:

 a) At least three child nodes

 b) At least two child nodes

 c) At least four child nodes

 d) No child nodes
Answer: a) At least three child nodes

20. Hierarchical data structures have what type of relationship?

 a) 1-to-1

 b) 1-to-many

 c) Many-to-many

 d) No relationship
Answer: b) 1-to-many

21. Stacks and queues are examples of:

 a) Circular data structures

 b) Hierarchical data structures

 c) Linear data structures

 d) Tree data structures


Answer: c) Linear data structures

22. What is one of the benefits of abstraction?

 a) Hides complex systems and makes things easy to understand

 b) Increases code execution speed


 c) Reduces code readability

 d) Adds unnecessary complexity


Answer: a) Hides complex systems and makes things easy to understand

23. In data abstraction, an address refers to:

 a) Its name in the program

 b) Its data type

 c) Its location in memory

 d) Its value
Answer: c) Its location in memory

24. What is the name in data abstraction?

 a) The label of the variable in the source code

 b) Its memory address

 c) Its data type

 d) Its scope in the program


Answer: a) The label of the variable in the source code

25. In data abstraction, scope refers to:

 a) The data type of the variable

 b) The memory address

 c) A set of statements where the variable is visible

 d) The length of the variable


Answer: c) A set of statements where the variable is visible

26. Which of the following is a hardware data type?

 a) Arrays

 b) Integers

 c) Structures
 d) Pointers
Answer: b) Integers

27. What is a virtual data type?

 a) A data type created by hardware

 b) A data type created by the operating system

 c) A data type created by the compiler

 d) A data type not represented in hardware


Answer: c) A data type created by the compiler

28. What does an abstract data type (ADT) do?

 a) Imposes limits based on the programming language

 b) Frees programmers from the limits of a programming language

 c) Enforces the programming language's built-in data types

 d) Reduces the complexity of coding


Answer: b) Frees programmers from the limits of a programming language

29. An array contains:

 a) Elements of different types

 b) Elements only of the same type

 c) Only numeric data

 d) Only string data


Answer: b) Elements only of the same type

30. How do you instantiate an array in Java?

 a) int arr[] = new array[3];

 b) int arr = new int[3];

 c) int arr[] = new int[3];

 d) arr[] = new int[3];


Answer: c) int arr[] = new int[3];
31. Which of the following is the correct syntax for declaring a multidimensional array in Java?

 a) int arr[ ][ ] = new int[3][3];

 b) int[][] arr = new int[3][3];

 c) int arr()[] = new int[3][3];

 d) arr[][] = new int[3][3];


Answer: b) int[][] arr = new int[3][3];

32. In an array, elements are accessed:

 a) Sequentially

 b) Randomly

 c) Recursively

 d) Only from the middle


Answer: b) Randomly

33. Which of the following is the correct way to declare an array in Java?

 a) int arr[] = new int(5);

 b) int [] arr = new int[5];

 c) int array[5];

 d) int arr = {5}; Answer: b) int [] arr = new int[5];

34. For sorting small arrays, which sorting algorithm runs faster?

 a) Bubble sort

 b) Merge sort

 c) Quick sort

 d) Insertion sort
Answer: d) Insertion sort

35. Which sorting algorithm does not require additional storage?

 a) Merge sort

 b) Quick sort
 c) Selection sort

 d) Insertion sort
Answer: c) Selection sort

36. Merge sort divides the array into two halves, sorts them individually, and:

 a) Swaps them

 b) Inserts them into an array

 c) Merges the two sorted halves

 d) Deletes the array


Answer: c) Merges the two sorted halves

37. Bottom-up merge sort implements sorting by:

 a) Recursively merging arrays

 b) Iteratively merging adjacent arrays of size 1, 2, etc.

 c) Reversing the elements of the array

 d) Creating sub-arrays and swapping them


Answer: b) Iteratively merging adjacent arrays of size 1, 2, etc.

38. Merge sort is called merging because:

 a) It combines the smallest elements

 b) It merges sorted versions of smaller arrays

 c) It swaps the elements

 d) It appends arrays at the end


Answer: b) It merges sorted versions of smaller arrays

39. Which of the following is the fastest known sorting algorithm?

 a) Merge sort

 b) Quick sort

 c) Shell sort
 d) Selection sort
Answer: b) Quick sort

40. Shell sort is an example of:

 a) Internal sorting

 b) External sorting

 c) Recursive sorting

 d) Merge sort
Answer: a) Internal sorting

41. Quick sort implements sorting by:

 a) Swapping elements

 b) Dividing and merging

 c) Partitioning the array about a pivot

 d) Sequentially scanning and sorting


Answer: c) Partitioning the array about a pivot

42. Shell sort is also known as:

 a) Partitioning sort

 b) Merging sort

 c) Diminishing increment sort

 d) Recursive sort
Answer: c) Diminishing increment sort

43. Shell sort is an example of:

 a) External sorting

 b) Internal sorting

 c) Recursion-based sorting

 d) Divide-and-conquer sorting
Answer: b) Internal sorting
44. In cryptography, a cipher is:

 a) A method to compress messages

 b) A method to decrypt messages

 c) A method to encrypt and decrypt messages

 d) A method to store messages


Answer: c) A method to encrypt and decrypt messages

45. In asymmetric key cryptography, the private key is:

 a) Shared with everyone

 b) Known only to the sender

 c) Kept only by the receiver

 d) Distributed to multiple parties


Answer: c) Kept only by the receiver

46. In cryptography, transpositional ciphers:

 a) Replace letters with numbers

 b) Rearrange the order of letters

 c) Encrypt the message using a key

 d) Do not alter the message


Answer: b) Rearrange the order of letters

47. Cryptanalysis is used to:

 a) Encrypt data more securely

 b) Analyze traffic on a network

 c) Find insecurities in a cryptographic scheme

 d) Improve data compression


Answer: c) Find insecurities in a cryptographic scheme

48. Cryptanalysis is a field of study where:


 a) Cryptographic schemes are tested for strength

 b) New encryption methods are created

 c) Cryptography is used to store data

 d) Information is hidden
Answer: a) Cryptographic schemes are tested for strength

49. TLS is a cryptographic protocol used to:

 a) Compress data

 b) Authenticate users

 c) Secure HTTP connections

 d) Encrypt emails
Answer: c) Secure HTTP connections

50. Voice privacy in GSM cellular protocols was provided by:

 a) A1/1 cipher

 b) A5/1 cipher

 c) A5/2 cipher

 d) A6/3 cipher
Answer: c) A5/2 cipher

51. Which of the following is not a principle of data security?

 a) Data confidentiality

 b) Data redundancy

 c) Data integrity

 d) Authentication
Answer: b) Data redundancy

52. Which of the following is a passive attack in data security?

 a) Masquerading

 b) Modification
 c) Traffic analysis

 d) Denial of service
Answer: c) Traffic analysis

53. In cryptography, a key is:

 a) A string of bits used by an algorithm to transform plain text into ciphertext

 b) A method for generating passwords

 c) A device used to store encryption algorithms

 d) A process of compressing data


Answer: a) A string of bits used by an algorithm to transform plain text into ciphertext

54. To encrypt plaintext, a cryptographic algorithm works in combination with:

 a) A function

 b) A password

 c) A key

 d) A compiler
Answer: c) A key

55. The QFront() operation in a queue returns:

 a) The last element

 b) The number of elements

 c) The first element

 d) The middle element


Answer: c) The first element

56. In a circular queue, the queue becomes full when:

 a) Rear equals front

 b) Rear equals front + 1

 c) Front is greater than rear by 1


 d) Rear is -1
Answer: c) Front is greater than rear by 1

57. A circular queue is empty when:

 a) Front equals rear + 1

 b) Front equals rear

 c) Front and rear are equal to -1

 d) Front is greater than rear


Answer: c) Front and rear are equal to -1

58. A queue implements which policy?

 a) Last-in, first-out (LIFO)

 b) First-in, first-out (FIFO)

 c) Circular order

 d) Priority order
Answer: b) First-in, first-out (FIFO)

59. The inchworm effect is noticeable when:

 a) Using a linked list-based queue

 b) Using a stack-based queue

 c) Using an array-based queue

 d) Using a tree-based queue


Answer: c) Using an array-based queue

60. What is the solution to the inchworm effect in array-based queues?

 a) Stacks

 b) Linked lists

 c) Circular queues

 d) Binary trees
Answer: c) Circular queues
61. The Queue.Front() operation:

 a) Returns the last element

 b) Returns the first element

 c) Adds an element to the queue

 d) Removes an element from the queue


Answer: b) Returns the first element

62. The operation Tenqueue(QFront() * 2):

 a) Removes the first element from the queue

 b) Enqueues a value two times the first element

 c) Doubles the queue size

 d) Enqueues an element at the rear


Answer: b) Enqueues a value two times the first element

63. The Dequeue() operation in a queue:

 a) Removes the element at the front

 b) Removes the element at the rear

 c) Adds an element at the front

 d) Adds an element at the rear


Answer: a) Removes the element at the front

64. In a circular queue, what happens after Dequeue() is called?

 a) The front element stays the same

 b) The queue becomes full

 c) The next oldest element becomes the front element

 d) The queue becomes empty


Answer: c) The next oldest element becomes the front element

65. The head pointer in data structures provides:


 a) The memory address location

 b) The value of the data

 c) The number of elements in the structure

 d) A pointer to the next element


Answer: a) The memory address location

66. A circular queue becomes full when:

 a) Rear equals front - 1

 b) Front equals rear

 c) Rear equals front + 1

 d) Front is greater than rear


Answer: b) Front equals rear

67. After a Dequeue() operation, which element becomes the front element?

 a) The oldest element

 b) The next oldest element

 c) The last inserted element

 d) The first element


Answer: b) The next oldest element

68. When an element is inserted into an empty queue, it becomes:

 a) The front element

 b) The rear element

 c) The head element

 d) The middle element


Answer: b) The rear element

69. The Dequeue() operation removes:

 a) The last element

 b) The middle element

 c) The element at the front


 d) The element at the rear
Answer: c) The element at the front

You might also like