Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Name: Subhajit Das College ID: O23MSD160112

Subject: Java_Programming

1. What is an object-oriented paradigm?

In technical terms, it’s a programming model organized around objects rather than actions.
Here’s a simple way to break it down:

 Objects: They’re the core of the system. Think of them as little capsules containing a
slice of a program. Like a music player on your phone is an object; it has buttons
(properties) and the ability to play music (methods).
 Classes: These are the blueprints for objects. A class outlines the properties and
methods that its objects will have, much like a cookie cutter shapes cookies.
 Inheritance: Objects can inherit characteristics from other objects, just like you might
inherit your eye color from a parent.
 Encapsulation: This is about keeping the details tucked away—objects keep their state
and behaviors neatly packaged and hidden from the outside.
 Polymorphism: It allows objects to be treated as instances of their parent class rather
than their actual class. Like a smartphone that can be treated as a phone, a camera, or a
music player.

So, in essence, object-oriented programming (OOP) is about organizing your code into
digestible chunks (objects) that can interact, have specific roles, and handle complexity by
hiding unnecessary details from the rest of the program. It’s a way to approach complex
problems by breaking them down into more manageable parts.

2. Can we modify the throws clause of the superclass method while overriding
it in the subclass?

Yes, we can modify the throws clause of a superclass method when overriding it in a subclass,
but there are certain rules you need to follow:

1. If the superclass method does not throw any exceptions, you can do the following in
the subclass:
o Not declare any throws clause.
o Declare unchecked exceptions (also known as runtime exceptions).

2. If the superclass method declares exceptions, in the subclass method you can:
o Omit the throws clause altogether.
o Throw the same exceptions as the superclass method or its subclasses.
o Throw different unchecked exceptions.
However, you cannot do the following:

 Throw broader checked exceptions than those declared by the superclass method.
 Throw additional checked exceptions not declared by the superclass method.

3. Differentiate between process and thread?

Certainly! Here’s a differentiation between a process and a thread:

 Process:
o A process is an independent execution unit containing its own set of instructions,
data, and resources allocated by the operating system.
o Each process has its own memory space, including a text section, data section,
and heap, which ensures that processes do not interfere with each other.
o Processes are heavier in terms of system resource usage and are more expensive
to create and manage.
o Inter-process communication is slower and more complex as processes have
separate memory spaces.
 Thread:
o A thread is the smallest unit of execution within a process. Threads within the
same process share the same memory space.
o Threads have their own stack but can access shared data, which allows for
efficient communication and data sharing.
o Threads are lightweight and have less overhead in terms of creation, context
switching, and management.
o Communication between threads is faster as they share the same memory space,
but this can lead to synchronization issues.

In summary, processes are isolated execution units with their own memory space, making
them secure and stable, but heavier on resources. Threads, being part of a process, are more
efficient but require careful programming to avoid issues with shared data. They are ideal for
tasks that require concurrent operations within the same application.

4. What is JDBC?

JDBC (Java Database Connectivity) is an API (Application Programming Interface) for the Java
programming language that defines how a client can access a database. Here are the key
points about JDBC:

1. Purpose of JDBC:
o JDBC provides a standard abstraction for Java applications to communicate with
various databases.
o It allows Java programs to interact with databases, execute queries, and handle
result sets.
o JDBC is used to write programs that access databases efficiently.
2. Components of JDBC:
o JDBC API: Provides methods and interfaces for communication with the database.
It includes the java.sql package (for data access in relational databases) and the
javax.sql package (for connection pooling in Java EE).
o JDBC Driver Manager: Loads database-specific drivers to establish connections.
o JDBC Test Suite: Used to test JDBC drivers’ operations.
o JDBC-ODBC Bridge Drivers: Connects JDBC to ODBC, translating method calls.
3. Key Interfaces and Classes:
o Interfaces: Driver, Connection, Statement, PreparedStatement,
CallableStatement, ResultSet, ResultSetMetaData, DatabaseMetaData, RowSet.
o Classes: DriverManager, Blob, Clob, Types.
4. What is the Collection framework in Java?

The Collection framework in Java is a comprehensive architecture that provides a set


of classes and interfaces for representing and manipulating collections of objects. Here
are the key aspects of the Java Collection framework:

 Hierarchy: At the top of the hierarchy is the Collection interface, which is


implemented by various classes like ArrayList, LinkedList, HashSet, and TreeSet.
The Map interface is also part of the framework but does not inherit from
Collection.
 Interfaces: The framework includes several interfaces, each with a specific
purpose:
o Set: A collection that cannot contain duplicate elements.
o List: An ordered collection that can contain duplicate elements.
o Queue: A collection used to hold multiple elements prior to processing.
o Deque: A double-ended queue that allows elements to be added or
removed from either end.

 Classes: There are concrete implementation classes for each of these


interfaces, such as:
o ArrayList and LinkedList for the List interface.
o HashSet, LinkedHashSet, and TreeSet for the Set interface.
o PriorityQueue and ArrayDeque for the Queue and Deque interfaces.

 Algorithms: The framework provides several algorithms that can be applied to


the collections, such as sorting and searching.
 Performance: Different collection classes have different performance
characteristics for various operations like adding, removing, and searching for
elements.
 Synchronization: Some collection classes are thread-safe, while others are not,
which is an important consideration for multi-threaded applications.
 Iterators: The framework provides Iterator and ListIterator interfaces for iterating
over collections.

You might also like