0% found this document useful (0 votes)
7 views

oop

Uploaded by

Onish's
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

oop

Uploaded by

Onish's
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

What is the difference between abstract classes and interfaces?

- Abstract classes can have abstract and concrete methods


- interfaces can only have abstract methods. A class can implement multiple
interfaces but can only extend one abstract class.

Explain the concept of method overloading and method overriding.


- Method overloading, allows a class to have multiple methods with the same name
but different parameters. methods must differ either in the number of parameters or
in the data types of the parameters.
-Method overriding, when a subclass provides a specific implementation of a method
that is already defined in its superclass. In this the method signatures must be
identical, (including the name, return type, and parameters.)

hat is the difference between static and non-static methods?


-Static methods belong to the class rather than any instance of the class. They can
be called without creating an instance of the class and cannot access instance
variables directly.
-Whereas non-static methods belong to the instance of the class. They can access
both static and non-static members of the class and require an instance of the
class to be called.

Object-Oriented Programming (OOP)


-programming paradigm where complete sw operates as a bunch of objects talking to
each other, It emphasizes modularity, reusability, and extensibility.
-4 principles op oop are Encapsulation, Inheritance, Polymorphism, and Abstraction

Encapsulation?
-it basically the bundling of data and methods that operate on the data into a
single unit, known as a class. It hides the internal state of an object and only
exposes the necessary methods to interact with it.

21)Inheritance?
-mechanism by which a class can inherit attributes and methods from another
class.it increase code reusability and it also achives runtime polymorphism

22)Polymorphism?
-ability of objects to take on multiple forms.
-of two types based on the time when the call to the object or function is
resolved.
-Compile-time Polymorphism (Static Polymorphism):
Compile-time polymorphism refers to the polymorphic behavior that is resolved at
compile time.
It is achieved through method overloding, where multiple methods with the same name
but different parameter lists are defined within the same class.
The appropriate method to execute is determined by the compiler based on the number
and types of arguments passed to the method.
-Runtime Polymorphism (Dynamic Polymorphism):
Runtime polymorphism refers to the polymorphic behavior that is resolved at
runtime.
It is achieved through method overriding, where a subclass provides a specific
implementation of a method that is already defined in its superclass.
The appropriate method to execute is determined by the JVM based on the type of the
object at runtime.

23)Abstraction?
-simplifies complex systems by modeling classes based on their essential
characteristics and ignoring irrelevant details. It enables the creation of
abstract data types and interfaces, allowing for code reuse and modular design.
24) difference between Composition and Inheritance?
-Composition involves creating complex objects by combining simpler objects. It
allows for better encapsulation and flexibility.
-Inheritance involves creating new classes based on existing ones, inheriting their
attributes and methods.it can lead to tight coupling and less flexibility.

25)What is the difference between a Class and an Object?


-class is a blueprint for creating objects. It defines the attributes and behaviors
that objects of that class will have.
-object is an instance of a class. It represents a specific instance of the class,
with its own set of attribute values.

What is the difference between ArrayList and LinkedList?


- ArrayList: Implements a dynamic array that can grow or shrink in size. Provides
fast access to elements but slower insertion and deletion operations.
- LinkedList: Implements a doubly linked list. Provides fast insertion and deletion
operations but slower access to elements.

What is the difference between StringBuffer and StringBuilder?


-StrngBuffer is synchronized, which makes it is thread-safe, but it is slower than
StringBulder.
-StrngBuilder is not synchronized, making it faster, but it is not thread-safe.

What are the differences between HashSet, TreeSet, and LinkedHashSet?


-HshSet: Set interface using a hsh table. It does not maintain the insertion order
of elements. HshSet allows one null element.
-tree Set: Implements the Sorted Set interface using a red-black tree. It maintains
the elements in sorted order either in natural order or according to a specified
comparator.it does not allow null elements
-LinkedHshSet: Extends HshSet and maintains the insertion order of elements using a
doubly linked list. It allows one null element and none of them are synchronised

You might also like