PRELIM DSAA Flashcards
What is a data structure?
A) A way to store and organize data
B) A type of programming language
C) A part of the operating system
D) A machine learning algorithm
A way to store and organize data
Which of the following is NOT a goal of data structures?
A) Correctness
B) Efficiency
C) Randomness
D) Fast searching and sorting
Randomness
What is an entity in data structures?
A) A specific type of file
B) A class of objects with attributes
C) A field in a database
D) A function in Java
A class of objects with attributes
Which of the following is a collection of various records of one type of entity?
A) Field
B) File
C) Record
D) Data
File
What is an array?
A) A collection of variables with different data types
B) A collection of items stored in contiguous memory locations
C) A dynamic data structure
D) A type of linked list
A collection of items stored in contiguous memory locations
Which of the following statements about arrays is true?
A) Arrays can store only primitive data types
B) Arrays are always dynamically resizable
C) Arrays can contain objects as well as primitive types
D) Arrays use linked nodes for storage
Arrays can contain objects as well as primitive types
What is the index of the last element in an array of size 10?
A) 9
B) 10
C) 0
D) 1
9
What will happen if you try to access an index that is out of bounds in Java?
A) The program runs normally
B) The array automatically resizes
C) An ArrayIndexOutOfBoundsException is thrown
D) The compiler converts it to the nearest valid index
An ArrayIndexOutOfBoundsException is thrown
Which Java package contains the ArrayList class?
A) java.lang
B) java.util
C) java.io
D) java.math
java.util
Which of the following is true about ArrayLists?
A) They are static in size
B) They use dynamic memory allocation
C) They do not allow duplicates
D) They store elements in a tree structure
They use dynamic memory allocation
What is the difference between an Array and an ArrayList?
A) Array has a fixed size, while ArrayList can grow dynamically
B) Array stores only objects, while ArrayList stores only primitive types
C) Array is a class, while ArrayList is a function
D) They are both identical
Array has a fixed size, while ArrayList can grow dynamically
Which method is used to remove an element from an ArrayList at a specific index?
A) remove(index)
B) delete(index)
C) erase(index)
D) clear(index)
remove(index)
What principle does a stack follow?
A) First In, First Out (FIFO)
B) Last In, First Out (LIFO)
C) Random access retrieval
D) Hierarchical storage
Last In, First Out (LIFO)
Which operation adds an element to the top of the stack?
A) enqueue()
B) pop()
C) push()
D) insert()
push()
Which operation removes the top element from the stack?
A) delete()
B) dequeue()
C) pop()
D) remove()
pop()
What does the peek() method do in a stack?
A) Removes the top element
B) Returns the top element without removing it
C) Searches for an element
D) Returns the size of the stack
Returns the top element without removing it
Which method checks if a stack is empty?
A) isEmpty()
B) clear()
C) hasElements()
D) exists()
isEmpty()
Which of the following is an example of an application of stacks?
A) Database indexing
B) Job scheduling
C) Infix to Postfix conversion
D) Network routing
Infix to Postfix conversion
Which of the following is true about the Stack class in Java?
A) It extends the ArrayList class
B) It implements the Queue interface
C) It extends the Vector class
D) It does not allow duplicate elements
It extends the Vector class
What is the main purpose of studying data structures?
A) To learn new programming languages
B) To understand how data is organized and managed efficiently
C) To improve network security
D) To create hardware components
To understand how data is organized and managed efficiently
What defines a data structure?
A) A structural representation of the logical relationship between data elements
B) A type of database management system
C) A high-level programming language
D) A type of file system
A structural representation of the logical relationship between data elements
Which of the following is NOT a feature of data structures?
A) Data storage
B) Data organization
C) Data destruction
D) Data retrieval
Data destruction
What is an entity in data structures?
A) A data type
B) A class of objects with attributes
C) A function in Java
D) A type of array
A class of objects with attributes
Which term refers to a collection of various data items?
A) Field
B) Record
C) File
D) Group
Record