Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

Data Structures and Algorithms → Introduction to DSA 35

Which keyword defines a class in Python?
class
click to copy
What is an object in Python OOP?
An instantiation of a class
click to copy
Which method is called automatically when an object is created?
__init__()
click to copy
What does 'self' represent in a Python class method?
Current instance of the class
click to copy
What is a class variable in Python?
Shared by all instances, defined outside constructor
click to copy
Which keyword makes a local variable refer to the global variable?
global
click to copy
Which type of method requires an object to be called?
Instance method
click to copy
Which decorator defines a class method?
@classmethod
click to copy
Which decorator defines a static method?
@staticmethod
click to copy
What parameter is the first argument in a class method?
cls
click to copy
What is a mutator (setter)?
Modifies value of instance variable
click to copy
How many types of inheritance are there in Python?
5
click to copy
In single inheritance, how many parent classes does a child have?
One
click to copy
Which inheritance has one child from two or more parents?
Multiple
click to copy
In multi-level inheritance, the structure is:
A child derived from another child class
click to copy
Which inheritance has two or more children from one parent?
Hierarchical
click to copy
What is hybrid inheritance?
Combination of more than one inheritance type
click to copy
What does polymorphism mean?
Multiple forms
click to copy
What is method overriding?
Child redefines parent's method
click to copy
Which module implements abstraction in Python?
abc
click to copy
What is an abstract method?
Has no implementation in base class
click to copy
What is an abstract class?
Class with at least one abstract method
click to copy
What does @property decorator do?
Access method as attribute without calling
click to copy
Which OOP concept hides unnecessary implementation details?
Abstraction
click to copy
Which OOP concept binds data and methods and restricts direct access?
Encapsulation
click to copy
Which is NOT a pillar of OOP?
Compilation
click to copy
What does __str__ method do?
Returns human-readable string of object
click to copy
What does __del__ method do?
Called when object is garbage collected
click to copy
What does super() do?
Calls parent class method from child
click to copy
Which relationship is represented by 'Dog IS-A Animal'?
Inheritance
click to copy
What prerequisite does binary search require?
Sorted list
click to copy
Binary search uses which algorithm technique?
Divide and conquer
click to copy
How is middle element calculated in binary search?
mid=(low+high)//2
click to copy
If search element > middle element, which half is searched?
Right half
click to copy
Time complexity of binary search?
O(log n)
click to copy

Data Structures and Algorithms → Searching Algorithms 5

What is linear search also called?
Sequential search
click to copy
Best case time complexity of linear search?
O(1)
click to copy
Worst case time complexity of linear search?
O(n)
click to copy
For what list size is linear search most suitable?
Smaller lists (<100)
click to copy
What does linear search return if element not found?
-1
click to copy