Company: Practo_SDE_Intern_MCQ
Difficulty: medium
In a vehicle tracking system, the Vehicle class has private fields for latitude and longitude and provides public methods updateLocation and getLocation. This design prevents the direct alteration of a vehicle's coordinates from outside the class. This scenario is an example of: Abstraction Inheritance Encapsulation Polymorphism Imagine you're developing a software system for a car manufacturer to model different types of vehicles. You have a base class Vehicle with subclasses Car, Truck, and Motorcycle. If the Car class adds a new method openTrunk() which is not present in Vehicle, this is an example of: Inheritance Aggregation Encapsulation Polymorphism You are implementing a search algorithm to find a specific element in a sorted array of integers. Which of the following algorithms would be the most efficient in terms of time complexity? Breadth-first search Linear search Binary search Depth-first search To implement an undo feature in a text editor, which allows reversing the last