Wipro Inteview Question

OOPs Concept for Interview

 1. 22. What is OOPs Concept And Why it is important : 

OOP (Object-Oriented Programming) is a programming paradigm based on the concept of "objects," which can contain data and code. The main OOP concepts are:

  1. Encapsulation: Bundling data and methods that operate on that data within an object.
  2. Inheritance: Creating new classes based on existing ones to promote code reuse.
  3. Polymorphism: Allowing methods to do different things based on the object that it is acting upon.
  4. Abstraction: Hiding complex implementation details and showing only the necessary features of an object.




Why is OOPS Important?

  • Code Reusability – Inheritance allows using existing code without rewriting.
  • Modularity – Encapsulation keeps code organized and manageable.
  • Flexibility & Scalability – Easy to modify and extend code.
  • Security – Data hiding prevents unauthorized access.
  • Better Problem Solving – Models real-world entities efficiently.


2. 23. Expain the basic Feature of OOPs:

The basic features of OOPs (Object-Oriented Programming) are:

  1. Encapsulation: Bundling data and methods within an object, restricting direct access to some components.
  2. Inheritance: Creating new classes from existing ones to reuse code and establish a hierarchy.
  3. Polymorphism: Allowing one interface to be used for different underlying data types or methods.
  4. Abstraction: Hiding complex implementation details and exposing only the necessary functionalities.

3. 24. What is difference between Class and Object:

class is a blueprint or template that defines the structure and behavior (data and methods) of objects. An object is an instance of a class, representing a specific entity with actual values and functionality based on the class definition.

4. 21. Why Java is called a Platform Independent Language :

Java is called a platform-independent language because it compiles code into bytecode, which can run on any device with a Java Virtual Machine (JVM), regardless of the underlying hardware and operating system.


5. What do you understand by Java ? 

Java is a high-level, object-oriented, platform-independent programming language developed by Sun Microsystems (now owned by Oracle). It follows the principle of "Write Once, Run Anywhere" (WORA), meaning Java programs can run on any platform with a Java Virtual Machine (JVM). It is widely used for building web applications, mobile applications (Android), enterprise software, and more. Java provides features like automatic memory management (Garbage Collection), multithreading, security, and a vast standard library, making it a popular choice for developers.



6. What is Pure OOP? Why Java is not pure OOP?

What is Pure OOP?

A pure OOP language is one that follows all the object-oriented programming (OOP) principles strictly. This means:

  • Everything in the language must be treated as an object.
  • There should be no primitive data types (like int, char, float).
  • Even basic operations should be done using objects.

Examples of pure OOP languages: Smalltalk, Eiffel


Why is Java Not a Pure OOP Language?

Java is not a pure OOP language because:

  1. It has primitive data types (int, char, float, boolean, etc.), which are not objects.
  2. It allows static methods (e.g., Math.sqrt()) that can be called without creating an object.
  3. It supports procedural programming (like writing simple functions inside main()).
  4. It has wrapper classes, but they are optional (e.g., Integer for int).

Since Java uses both OOP and primitive types, it is considered "object-oriented" but not purely object-oriented.


7. What is Differences between Inheritance and Polymorphism.

Differences Between Inheritance and Polymorphism

FeatureInheritancePolymorphism
DefinitionAllows one class to acquire properties and behaviors of another class.Allows one action to be performed in different ways.
PurposeCode reusability (avoiding code duplication).Flexibility (same function working differently).
Types- Single Inheritance
- Multilevel Inheritance
- Hierarchical Inheritance
- Multiple & Hybrid (Not in Java)
- Method Overloading (Compile-time Polymorphism)
- Method Overriding (Runtime Polymorphism)
How it WorksA child class gets properties and methods from a parent class using extends keyword.The same method behaves differently based on input (overloading) or object type (overriding).
Example in Javajava class A { int x; } class B extends A { int y; }java class A { void show() {} } class B extends A { void show() {} }
Real-Life ExampleA child inherits eye color from parents.A person behaves differently as a student and as a friend.

Key Takeaway:

  • Inheritance is about reusing properties from a parent class.
  • Polymorphism is about making the same function work differently in different scenarios.



7. What is Encapsulation ?

What is Encapsulation?

Encapsulation is the hiding of data inside a class and allowing access only through methods. It protects data from being directly modified by restricting access using access modifiers like private, public, and protected.

Example in Java:

java
class BankAccount { private double balance; // Private data, can't be accessed directly public void setBalance(double amount) { // Setter method if (amount > 0) { balance = amount; } } public double getBalance() { // Getter method return balance; } } public class Main { public static void main(String[] args) { BankAccount acc = new BankAccount(); acc.setBalance(1000); // Setting value using method System.out.println(acc.getBalance()); // Getting value using method } }

Why is Encapsulation Important?

Data Security – Prevents direct modification of variables.
Code Flexibility – Can change the implementation without affecting other parts.
Easy Maintenance – Improves code readability and debugging.

Encapsulation ensures data safety and control, making programs more secure and organized.



8. What is Access Modifiers ?

Comments