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

OOP, Data Structures, SQL & JS MCQs

Uploaded by

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

OOP, Data Structures, SQL & JS MCQs

Uploaded by

rifatkhantarif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

📘 OOP (Object-Oriented Programming)

Key Topics:

●​ Classes & Objects


●​ Encapsulation, Inheritance, Polymorphism, Abstraction
●​ Constructors / this keyword
●​ Method Overriding vs Overloading
●​ Access Modifiers (public/private/protected)

📘 Data Structures & Algorithms


Key Topics:

●​ Arrays, Linked Lists, Stacks, Queues


●​ Sorting (Bubble, Selection, Quick, Merge)
●​ Searching (Binary Search)
●​ Time & Space Complexity (Big O)
●​ Hash Tables, Trees, Graphs (basics)

📘 SQL
Key Topics:

●​ SELECT, INSERT, UPDATE, DELETE


●​ WHERE, GROUP BY, ORDER BY, HAVING
●​ JOINS (INNER, LEFT, RIGHT, FULL)
●​ Aggregate Functions (COUNT, SUM, AVG)
●​ Constraints (PRIMARY KEY, FOREIGN KEY)

📘 Basic JavaScript (for Web Applications)


Key Topics:

●​ Data types & variables


●​ Functions (declaration, arrow functions)
●​ DOM manipulation
●​ Event handling
●​ Array methods (map, filter, reduce)
●​ Scope & Hoisting
●​ let vs var vs const
🧱 OOP – Object-Oriented Programming (20
MCQs)
1.​Which of the following is not an OOP concept?
○​ a) Encapsulation
○​ b) Inheritance
○​ c) Compilation ✅
○​ d) Polymorphism​

2.​What is encapsulation in OOP?


○​ a) Hiding the internal state✅
○​ b) Creating subclasses
○​ c) Reusing code
○​ d) Overloading methods​

3.​Which OOP principle allows code reuse?


○​ a) Abstraction
○​ b) Inheritance ✅
○​ c) Encapsulation
○​ d) Polymorphism​

4.​What does polymorphism allow in OOP?


a) Multiple classes in one file

○​
○​ b) Same function name with different implementations
○​ c) Creating new objects
○​ d) Creating private members​

5.​What is the default access modifier in most OOP languages?


○​ a) private ✅
○​ b) public
○​ c) protected
○​ d) package-private (language dependent)​

6.​Which of the following enables runtime polymorphism?


○​ a) Method overloading
○​ b) Method overriding ✅
○​ c) Operator overloading
○​ d) Function hiding​

7.​What is the use of the this keyword?


a) Refers to global variables

○​
○​ b) Refers to the current class instance
○​ c) Deletes object
○​ d) Creates new object​
8.​Constructors are:
○​ a) Used to destroy an object
○​ b) A special method to initialize objects ✅
○​ c) Static methods
○​ d) Methods that must return a value​

9.​Which concept hides the internal details and shows only


functionality?
○​ a) Encapsulation
○​ b) Inheritance
○​ c) Abstraction ✅
○​ d) Polymorphism​

10.​ In which situation would you use method overloading?


○​ a) When return types are different
b) When method names differ

○​
○​ c) When parameter lists differ
○​ d) When class names differ​

11.​ Which keyword is used to inherit a class in Java?


○​ a) implements
○​ b) inherits
○​ c) ✅
extends
○​ d) super​

12.​ Which principle is being violated if one class relies


heavily on another class's internal details?
○​ a) Abstraction
○​ b) Tight coupling ✅
○​ c) Loose coupling
○​ d) Inheritance​

13.​ What is a subclass also called?​

○​ a) Base class
b) Superclass

○​
○​ c) Derived class
○​ d) Static class​

What is the output of:​



js​
CopyEdit​
class A {

constructor() {
[Link] = 5;

let obj = new A();

[Link]([Link]);

14.​
○​ a) ✅
5
○​ b) undefined
○​ c) Error
○​ d) null​

15.​ What type of inheritance allows a class to have multiple


parent classes?
○​ a) Multilevel
○​ b) Multiple ✅
○​ c) Hierarchical
○​ d) Hybrid​

16.​ What keyword is used to call the parent class constructor?


○​ a) parent()
○​ b) super() ✅
○​ c) base()
○​ d) this()​

17.​ What is the main advantage of encapsulation?


○​ a) Fast execution
○​ b) Code reusability
○​ c) Data hiding ✅
○​ d) Memory management​

18.​ Which one is true for abstract classes?


○​ a) Cannot have methods
○​ b) Must be instantiated
○​ c) ✅
Can have both abstract and non-abstract methods
○​ d) All methods must be abstract​

19.​ Composition means:


○​ a) Creating objects
○​ b) Using objects of other classes inside a class ✅
○​ c) Inheriting a class
○​ d) Declaring private methods​
20.​ Which of these is a violation of encapsulation?​

○​ a) Exposing all fields as public ✅


○​ b) Using private fields
○​ c) Providing getters and setters
○​ d) Using constructors​

🧠 Data Structures & Algorithms (20 MCQs)


1.​ Which data structure follows FIFO?


○​ a) Stack
○​ b) Queue
○​ c) Array
○​ d) Linked List​

2.​ What is the worst-case time complexity of Binary Search?


○​ a) O(n)
○​ b) O(log n)
○​ c) O(n log n)
○​ d) O(1)​

3.​ Which sorting algorithm is best for nearly sorted data?


○​ a) Bubble Sort


○​ b) Merge Sort
○​ c) Insertion Sort
○​ d) Quick Sort​

4.​ Which of the following is a linear data structure?


○​ a) Tree


○​ b) Graph
○​ c) Stack
○​ d) Hash Table​

5.​ In which scenario would you use a HashMap?


○​ a) Ordered data
○​ b) Fast lookup
○​ c) Recursive calls
○​ d) Sorting data​

6.​ Which is not a stable sorting algorithm?


○​ a) Merge Sort
○​ b) Quick Sort
○​ c) Bubble Sort
○​ d) Insertion Sort


7.​ What is the auxiliary space of merge sort?
○​ a) O(n)
○​ b) O(log n)
○​ c) O(1)
○​ d) O(n log n)​

8.​ What does a linked list consist of?


○​ a) Nodes
○​ b) Arrays


○​ c) Pointers
○​ d) Both a and c ​

9.​ How many children can a binary tree node have?


○​ a) 1
○​ b) 2
○​ c) Any
○​ d) Infinite​

10.​What is a leaf node?


○​ a) Node with one child


○​ b) Node with two children
○​ c) Node with no children
○​ d) Root node​

11.​Which traversal is used in depth-first search?


○​ a) Level Order


○​ b) Breadth First
○​ c) Inorder/Preorder/Postorder
○​ d) None​

12.​What is the result of a stack-based postfix evaluation of: 5 3 2 * +?


○​ a) 16
○​ b) 11
○​ c) 10
○​ d) 21​

13.​Which data structure is best for implementing undo functionality?


○​ a) Queue
○​ b) Stack
○​ c) Heap
○​ d) Tree

14.​Which of these is used in recursive algorithms?


○​ a) Queue


○​ b) Array
○​ c) Stack
○​ d) Tree​
15.​What’s the time complexity of accessing an element in an array?


○​ a) O(n)
○​ b) O(1)
○​ c) O(log n)
○​ d) O(n log n)​

16.​Which operation takes constant time in a stack?


○​ a) Traversal


○​ b) Deletion from middle
○​ c) Push/Pop
○​ d) Sorting​

17.​Which sorting algorithm is divide and conquer?


○​ a) Bubble Sort
○​ b) Quick Sort
○​ c) Selection Sort
○​ d) Insertion Sort​

18.​What is the maximum number of edges in an undirected graph with n vertices?


○​ a) n
○​ b) n(n−1)/2
○​ c) 2n
○​ d) n²​

19.​Which of the following is not a tree traversal?


○​ a) Preorder
○​ b) Postorder


○​ c) Inorder
○​ d) Roundorder ​

20.​A priority queue is typically implemented using:


○​ a) Stack


○​ b) Linked List
○​ c) Heap
○​ d) Queue

🛢️ SQL – Structured Query Language (20 MCQs +


Answers)
1.​ Which SQL statement is used to retrieve data?​

○​ a) GET​

○​ ✅ b) SELECT​
○​ c) EXTRACT​

○​ d) FETCH​

2.​ Which clause is used to filter rows?​

○​ a) ORDER BY​

○​ b) GROUP BY​

○​ ✅ c) WHERE​
○​ d) HAVING​

3.​ How do you select all the columns from a table named users?​

○​ a) SELECT ALL FROM users;​

○​ b) GET * FROM users;​

○​ ✅ c) SELECT * FROM users;​


○​ d) SHOW * FROM users;​

4.​ What does NULL represent in SQL?​

○​ a) Zero​

○​ b) Empty String​

○​ ✅ c) Missing or undefined value​


○​ d) False​

5.​ Which SQL keyword is used to sort results?​

○​ a) FILTER​

○​ ✅ b) ORDER BY​
○​ c) SORT​

○​ d) RANK​

6.​ What command is used to remove a table?​


○​ a) REMOVE TABLE​

○​ ✅ b) DROP TABLE​
○​ c) DELETE TABLE​

○​ d) CLEAR TABLE​

7.​ Which function returns the number of rows?​

○​ a) SUM()​

○​ b) COUNT()​

○​ ✅ c) COUNT()​
○​ d) TOTAL()​

8.​ Which operator is used with WHERE to match a pattern?​

○​ a) =​

○​ b) ==​

○​ ✅ c) LIKE​
○​ d) MATCH​

9.​ How do you retrieve only unique values?​

○​ a) SELECT only​

○​ ✅ b) SELECT DISTINCT​
○​ c) SELECT UNIQUE​

○​ d) SELECT NON-DUPLICATE​

10.​Which clause is used with aggregate functions?​

○​ a) ORDER BY​

○​ b) WHERE​

○​ c) SELECT​
○​ ✅ d) GROUP BY​
11.​What does JOIN do?​

○​ ✅ a) Combines rows from two or more tables​


○​ b) Removes duplicates​

○​ c) Creates a table​

○​ d) Drops a table​

12.​What is a primary key?​

○​ ✅ a) A unique identifier for a row​


○​ b) A foreign key​

○​ c) A table name​

○​ d) A column with duplicates​

13.​Which of the following modifies existing records?​

○​ a) SELECT​

○​ b) INSERT​

○​ ✅ c) UPDATE​
○​ d) ALTER​

14.​Which command deletes all rows but not the table structure?​

○​ a) DROP​

○​ ✅ b) TRUNCATE​
○​ c) DELETE​

○​ d) REMOVE​

15.​What does HAVING filter?​

○​ a) Column values​
○​ b) Table names​

○​ ✅ c) Aggregate function results​


○​ d) Aliases​

16.​What keyword adds new data?​

○​ a) ADD​

○​ ✅ b) INSERT INTO​
○​ c) UPDATE​

○​ d) APPEND​

17.​What constraint prevents NULL values?​

○​ a) DEFAULT​

○​ ✅ b) NOT NULL​
○​ c) UNIQUE​

○​ d) FOREIGN KEY​

18.​Which clause limits the number of returned rows?​

○​ a) TOP​

○​ ✅ b) LIMIT (MySQL/SQLite)​
○​ c) FIRST​

○​ d) MAX​

19.​Which function returns the highest value?​

○​ a) COUNT()​

○​ ✅ b) MAX()​
○​ c) TOP()​

○​ d) HIGH()​

20.​What is the correct syntax for a foreign key?​


○​ a) FOREIGN KEY REFERENCES table(column)​

○​ ✅ b) FOREIGN KEY (column) REFERENCES table(column)​


○​ c) CREATE FOREIGN KEY ON column​

○​ d) SET FOREIGN KEY = column​

💻 JavaScript – Web Programming (20 MCQs +


Answers)
1.​ Which type is not a JavaScript primitive?​

○​ a) Number​

○​ b) Boolean​

○​ ✅ c) Object​
○​ d) String​

2.​ Which operator checks both value and type?​

○​ a) =​

○​ b) ==​

○​ ✅ c) ===​
○​ d) !=​

3.​ What will typeof null return?​

○​ a) "null"​

○​ ✅ b) "object"​
○​ c) "undefined"​

○​ d) "boolean"​

4.​ Which method adds an item to the end of an array?​


○​ a) shift()​

○​ ✅ b) push()​
○​ c) unshift()​

○​ d) pop()​

5.​ What is the result of NaN === NaN?​

○​ ✅ a) false​
○​ b) true​

○​ c) undefined​

○​ d) NaN​

6.​ What is the output of [Link](typeof [])?​

○​ ✅ a) object​
○​ b) array​

○​ c) list​

○​ d) undefined​

7.​ Which function converts JSON to an object?​

○​ a) [Link]()​

○​ ✅ b) [Link]()​
○​ c) [Link]()​

○​ d) [Link]()​

8.​ What is the default value of an uninitialized variable?​

○​ ✅ a) undefined​
○​ b) null​

○​ c) 0​
○​ d) false​

9.​ Which loop runs at least once?​

○​ a) for​

○​ b) while​

○​ ✅ c) do...while​
○​ d) forEach​

10.​How to declare a constant in JavaScript?​

○​ a) let x = 5;​

○​ b) var x = 5;​

○​ ✅ c) const x = 5;​
○​ d) define x = 5;​

11.​Which keyword declares a block-scoped variable?​

○​ a) var​

○​ ✅ b) let​
○​ c) const​

○​ d) define​

12.​What will Boolean("") return?​

○​ ✅ a) false​
○​ b) true​

○​ c) undefined​

○​ d) Error​

13.​What is a closure?​

○​ ✅ a) A function with access to its outer scope even after execution​


○​ b) A class​

○​ c) An event​

○​ d) A method​

14.​What is the output of: 2 + "2"?​

○​ a) 4​

○​ ✅ b) "22"​
○​ c) NaN​

○​ d) Error​

15.​What is hoisting in JavaScript?​

○​ ✅ a) Variable/function declarations moved to the top of scope​


○​ b) Loop optimization​

○​ c) Event bubbling​

○​ d) Memory leak​

16.​How do you prevent default form behavior?​

○​ a) stopPropagation()​

○​ ✅ b) [Link]()​
○​ c) block()​

○​ d) return false​

17.​What’s the output of typeof undefined?​

○​ ✅ a) "undefined"​
○​ b) null​

○​ c) NaN​

○​ d) "object"​
18.​Which method removes the last item in an array?​

○​ a) shift()​

○​ ✅ b) pop()​
○​ c) splice()​

○​ d) delete()​

19.​What does setTimeout(fn, 0) do?​

○​ ✅ a) Schedules fn to run after the current call stack​


○​ b) Immediately runs fn​

○​ c) Blocks the stack​

○​ d) Loops fn​

20.​Which array method filters items based on a condition?​

○​ a) map()​

○​ ✅ b) filter()​
○​ c) reduce()​

○​ d) find()​

You might also like