0% found this document useful (0 votes)
423 views91 pages

DBMS OS CN OOPs MostFrequentlyAskedQuestions

This document serves as a comprehensive guide for preparing for technical interviews, focusing on frequently asked questions in areas such as DBMS, Operating Systems, OOPs, and Computer Networks. It provides detailed explanations of key concepts, definitions, and advantages related to database management systems, including normalization, data abstraction, and various types of database languages. The resource aims to equip candidates with essential knowledge to confidently tackle technical interview questions.

Uploaded by

Pradeep Jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
423 views91 pages

DBMS OS CN OOPs MostFrequentlyAskedQuestions

This document serves as a comprehensive guide for preparing for technical interviews, focusing on frequently asked questions in areas such as DBMS, Operating Systems, OOPs, and Computer Networks. It provides detailed explanations of key concepts, definitions, and advantages related to database management systems, including normalization, data abstraction, and various types of database languages. The resource aims to equip candidates with essential knowledge to confidently tackle technical interview questions.

Uploaded by

Pradeep Jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 91

Introduction

Welcome to the ultimate resource for acing technical interviews! This sheet is a comprehensive compilation of the
most frequently asked questions across product-based companies, service-based companies, and startups. It
covers essential topics like DBMS, Operating Systems (OS), Object-Oriented Programming (OOPs), and
Computer Networks—core subjects that are vital for any technical role.

Whether you're preparing for your first interview or brushing up for an advanced role, this sheet ensures you're
equipped with the right knowledge to tackle the toughest questions confidently.

A huge shoutout to Javatpoint and GeeksforGeeks for their incredible content that served as a reference and
inspiration. Their dedication to creating high-quality educational material has been instrumental in shaping this guide.

For more insightful content and in-depth explanations, check out my YouTube channel:
https://www.youtube.com/@shivamlucknowi

Let’s get started and take a step closer to cracking your dream job! 🚀
DBMS Interview Questions
A list of top frequently asked DBMS interview questions and answers are given below.

1) What is DBMS?
DBMS is a collection of programs that facilitates users to create and maintain a
database. In other words, DBMS provides us an interface or tool for performing
different operations such as the creation of a database, inserting data into it,
deleting data from it, updating the data, etc. DBMS is a software in which data is
stored in a more secure way as compared to the file-based system. Using DBMS,
we can overcome many problems such as- data redundancy, data inconsistency,
easy access, more organized and understandable, and so on. There is the name of
some popular Database Management System- MySQL, Oracle, SQL Server,
Amazon simple DB (Cloud-based), etc.

Working of DBMS is defined in the figure below.

2) What is a database?
A Database is a logical, consistent and organized collection of data that it can
easily be accessed, managed and updated. Databases, also known as electronic
databases are structured to provide the facility of creation, insertion, updating of
the data efficiently and are stored in the form of a file or set of files, on the
magnetic disk, tapes and another sort of secondary devices. Database mostly
consists of the objects (tables), and tables include of the records and fields. Fields
are the basic units of data storage, which contain the information about a
particular aspect or attribute of the entity described by the database. DBMS is
used for extraction of data from the database in the form of the queries.

3) What is a database system?


The collection of database and DBMS software together is known as a database
system. Through the database system, we can perform many activities such as-

The data can be stored in the database with ease, and there are no issues of data
redundancy and data inconsistency.

The data will be extracted from the database using DBMS software whenever
required. So, the combination of database and DBMS software enables one to
store, retrieve and access data with considerate accuracy and security.

4) What are the advantages of DBMS?


○ Redundancy control
○ Restriction for unauthorized access
○ Provides multiple user interfaces
○ Provides backup and recovery
○ Enforces integrity constraints
○ Ensure data consistency
○ Easy accessibility
○ Easy data extraction and data processing due to the use of queries

5) What is a checkpoint in DBMS?


The Checkpoint is a type of mechanism where all the previous logs are removed
from the system and permanently stored in the storage disk.

There are two ways which can help the DBMS in recovering and maintaining the
ACID properties, and they are- maintaining the log of each transaction and
maintaining shadow pages. So, when it comes to log based recovery system,
checkpoints come into existence. Checkpoints are those points to which the
database engine can recover after a crash as a specified minimal point from
where the transaction log record can be used to recover all the committed data
up to the point of the crash.

6) When does checkpoint occur in DBMS?


A checkpoint is like a snapshot of the DBMS state. Using checkpoints, the DBMS
can reduce the amount of work to be done during a restart in the event of
subsequent crashes. Checkpoints are used for the recovery of the database after
the system crash. Checkpoints are used in the log-based recovery system. When
due to a system crash we need to restart the system then at that point we use
checkpoints. So that, we don't have to perform the transactions from the very
starting.

7) What do you mean by transparent DBMS?


The transparent DBMS is a type of DBMS which keeps its physical structure
hidden from users. Physical structure or physical storage structure implies to the
memory manager of the DBMS, and it describes how the data stored on disk.

8) What are the unary operations in Relational Algebra?


PROJECTION and SELECTION are the unary operations in relational algebra.
Unary operations are those operations which use single operands. Unary
operations are SELECTION, PROJECTION, and RENAME.

As in SELECTION relational operators are used for example - =,<=,>=, etc.

9) What is RDBMS?
RDBMS stands for Relational Database Management Systems. It is used to
maintain the data records and indices in tables. RDBMS is the form of DBMS
which uses the structure to identify and access data concerning the other piece
of data in the database. RDBMS is the system that enables you to perform
different operations such as- update, insert, delete, manipulate and administer a
relational database with minimal difficulties. Most of the time RDBMS use SQL
language because it is easily understandable and is used for often.

10) How many types of database languages are?


There are four types of database languages:

○ Data Definition Language (DDL) e.g., CREATE, ALTER, DROP,


TRUNCATE, RENAME, etc. All these commands are used for updating
the data that?s why they are known as Data Definition Language.
○ Data Manipulation Language (DML) e.g., SELECT, UPDATE, INSERT,
DELETE, etc. These commands are used for the manipulation of already
updated data that's why they are the part of Data Manipulation
Language.
○ DATA Control Language (DCL) e.g., GRANT and REVOKE. These
commands are used for giving and removing the user access on the
database. So, they are the part of Data Control Language.
○ Transaction Control Language (TCL) e.g., COMMIT, ROLLBACK, and
SAVEPOINT. These are the commands used for managing transactions
in the database. TCL is used for managing the changes made by DML.

Database language implies the queries that are used for the update, modify and
manipulate the data.

11) What do you understand by Data Model?


The Data model is specified as a collection of conceptual tools for describing
data, data relationships, data semantics and constraints. These models are used
to describe the relationship between the entities and their attributes.

There is the number of data models:

○ Hierarchical data model


○ network model
○ relational model
○ Entity-Relationship model and so on.
12) Define a Relation Schema and a Relation.
A Relation Schema is specified as a set of attributes. It is also known as table
schema. It defines what the name of the table is. Relation schema is known as
the blueprint with the help of which we can explain that how the data is
organized into tables. This blueprint contains no data.

A relation is specified as a set of tuples. A relation is the set of related attributes


with identifying key attributes

See this example:

Let r be the relation which contains set tuples (t1, t2, t3, ..., tn). Each tuple is an
ordered list of n-values t=(v1,v2, ...., vn).

13) What is a degree of Relation?


The degree of relation is a number of attribute of its relation schema. A degree of
relation is also known as Cardinality it is defined as the number of occurrence of
one entity which is connected to the number of occurrence of other entity. There
are three degree of relation they are one-to-one(1:1), one-to-many(1:M),
many-to-one(M:M).

14) What is the Relationship?


The Relationship is defined as an association among two or more entities. There
are three type of relationships in DBMS-

One-To-One: Here one record of any object can be related to one record of
another object.

One-To-Many (many-to-one): Here one record of any object can be related to


many records of other object and vice versa.

Many-to-many: Here more than one records of an object can be related to n


number of records of another object.
15) What are the disadvantages of file processing systems?

○ Inconsistent
○ Not secure
○ Data redundancy
○ Difficult in accessing data
○ Data isolation
○ Data integrity
○ Concurrent access is not possible
○ Limited data sharing
○ Atomicity problem

16) What is data abstraction in DBMS?


Data abstraction in DBMS is a process of hiding irrelevant details from users.
Because database systems are made of complex data structures so, it makes
accessible the user interaction with the database.

For example: We know that most of the users prefer those systems which have a
simple GUI that means no complex processing. So, to keep the user tuned and
for making the access to the data easy, it is necessary to do data abstraction. In
addition to it, data abstraction divides the system in different layers to make the
work specified and well defined.

17) What are the three levels of data abstraction?


Following are three levels of data abstraction:

Physical level: It is the lowest level of abstraction. It describes how data are stored.

Logical level: It is the next higher level of abstraction. It describes what data are
stored in the database and what the relationship among those data is.

View level: It is the highest level of data abstraction. It describes only part of the
entire database.
For example- User interacts with the system using the GUI and fill the required
details, but the user doesn't have any idea how the data is being used. So, the
abstraction level is entirely high in VIEW LEVEL.

Then, the next level is for PROGRAMMERS as in this level the fields and records
are visible and the programmers have the knowledge of this layer. So, the level of
abstraction here is a little low in VIEW LEVEL.

And lastly, physical level in which storage blocks are described.

18) What is DDL (Data Definition Language)?


Data Definition Language (DDL) is a standard for commands which defines the
different structures in a database. Most commonly DDL statements are CREATE,
ALTER, and DROP. These commands are used for updating data into the
database.

19) What is DML (Data Manipulation Language)?


DData Manipulation Language (DML) is a language that enables the user to
access or manipulate data as organized by the appropriate data model. For
example- SELECT, UPDATE, INSERT, DELETE.

There is two type of DML:

Procedural DML or Low level DML: It requires a user to specify what data are
needed and how to get those data.

Non-Procedural DML or High level DML:It requires a user to specify what data are
needed without specifying how to get those data.

20) Explain the functionality of DML Compiler.


The DML Compiler translates DML statements in a query language that the
query evaluation engine can understand. DML Compiler is required because the
DML is the family of syntax element which is very similar to the other
programming language which requires compilation. So, it is essential to compile
the code in the language which query evaluation engine can understand and
then work on those queries with proper output.

21) What is Relational Algebra?


Relational Algebra is a Procedural Query Language which contains a set of
operations that take one or two relations as input and produce a new
relationship. Relational algebra is the basic set of operations for the relational
model. The decisive point of relational algebra is that it is similar to the algebra
which operates on the number.

There are few fundamental operations of relational algebra:

○ select
○ project
○ set difference
○ union
○ rename,etc.

22) What is Relational Calculus?


Relational Calculus is a Non-procedural Query Language which uses
mathematical predicate calculus instead of algebra. Relational calculus doesn't
work on mathematics fundamentals such as algebra, differential, integration, etc.
That's why it is also known as predicate calculus.

There is two type of relational calculus:

○ Tuple relational calculus


○ Domain relational calculus

23) What do you understand by query optimization?


The term query optimization specifies an efficient execution plan for evaluating a
query that has the least estimated cost. The concept of query optimization came
into the frame when there were a number of methods, and algorithms existed for
the same task then the question arose that which one is more efficient and the
process of determining the efficient way is known as query optimization.

There are many benefits of query optimization:

○ It reduces the time and space complexity.


○ More queries can be performed as due to optimization every query
comparatively takes less time.
○ User satisfaction as it will provide output fast

24) What do you mean by durability in DBMS?


Once the DBMS informs the user that a transaction has completed successfully,
its effect should persist even if the system crashes before all its changes are
reflected on disk. This property is called durability. Durability ensures that once
the transaction is committed into the database, it will be stored in the
non-volatile memory and after that system failure cannot affect that data
anymore.

25) What is normalization?


Normalization is a process of analysing the given relation schemas according to
their functional dependencies. It is used to minimize redundancy and also used
to minimize insertion, deletion and update distractions. Normalization is
considered as an essential process as it is used to avoid data redundancy,
insertion anomaly, updation anomaly, deletion anomaly.

There most commonly used normal forms are:

○ First Normal Form(1NF)


○ Second Normal Form(2NF)
○ Third Normal Form(3NF)
○ Boyce & Codd Normal Form(BCNF)
26) What is Denormalization?
Denormalization is the process of boosting up database performance and adding
of redundant data which helps to get rid of complex data. Denormalization is a
part of database optimization technique. This process is used to avoid the use of
complex and costly joins. Denormalization doesn't refer to the thought of not to
normalize instead of that denormalization takes place after normalization. In this
process, firstly the redundancy of the data will be removed using normalization
process than through denormalization process we will add redundant data as
per the requirement so that we can easily avoid the costly joins.

27) What is functional Dependency?


Functional Dependency is the starting point of normalization. It exists when a
relation between two attributes allow you to determine the corresponding
attribute's value uniquely. The functional dependency is also known as database
dependency and defines as the relationship which occurs when one attribute in
a relation uniquely determines another attribute. It is written as A->B which
means B is functionally dependent on A.

28) What is the E-R model?


E-R model is a short name for the Entity-Relationship model. This model is based
on the real world. It contains necessary objects (known as entities) and the
relationship among these objects. Here the primary objects are the entity,
attribute of that entity, relationship set, an attribute of that relationship set can
be mapped in the form of E-R diagram.

In E-R diagram, entities are represented by rectangles, relationships are


represented by diamonds, attributes are the characteristics of entities and
represented by ellipses, and data flow is represented through a straight line.

29) What is an entity?


The Entity is a set of attributes in a database. An entity can be a real-world object
which physically exists in this world. All the entities have their attribute which in
the real world considered as the characteristics of the object.
For example: In the employee database of a company, the employee,
department, and the designation can be considered as the entities. These
entities have some characteristics which will be the attributes of the
corresponding entity.

30) What is an Entity type?


An entity type is specified as a collection of entities, having the same attributes.
Entity type typically corresponds to one or several related tables in the database.
A characteristic or trait which defines or uniquely identifies the entity is called
entity type.

For example, a student has student_id, department, and course as its


characteristics.

31) What is an Entity set?


The entity set specifies the collection of all entities of a particular entity type in
the database. An entity set is known as the set of all the entities which share the
same properties.

For example, a set of people, a set of students, a set of companies, etc.

32) What is an Extension of entity type?


An extension of an entity type is specified as a collection of entities of a particular
entity type that are grouped into an entity set.

33) What is Weak Entity set?


An entity set that doesn't have sufficient attributes to form a primary key is
referred to as a weak entity set. The member of a weak entity set is known as a
subordinate entity. Weak entity set does not have a primary key, but we need a
mean to differentiate among all those entries in the entity set that depend on
one particular strong entity set.
34) What is an attribute?
An attribute refers to a database component. It is used to describe the property
of an entity. An attribute can be defined as the characteristics of the entity.
Entities can be uniquely identified using the attributes. Attributes represent the
instances in the row of the database.

For example: If a student is an entity in the table then age will be the attribute of
that student.

35) What are the integrity rules in DBMS?


Data integrity is one significant aspect while maintaining the database. So, data
integrity is enforced in the database system by imposing a series of rules. Those
set of integrity is known as the integrity rules.

There are two integrity rules in DBMS:

Entity Integrity : It specifies that "Primary key cannot have a NULL value."

Referential Integrity: It specifies that "Foreign Key can be either a NULL value or
should be the Primary Key value of other relation

36) What do you mean by extension and intension?


Extension: The Extension is the number of tuples present in a table at any
instance. It changes as the tuples are created, updated and destroyed. The actual
data in the database change quite frequently. So, the data in the database at a
particular moment in time is known as extension or database state or snapshot.
It is time dependent.

Intension: Intension is also known as Data Schema and defined as the description
of the database, which is specified during database design and is expected to
remain unchanged. The Intension is a constant value that gives the name,
structure of tables and the constraints laid on it.
37) What is System R? How many of its two major
subsystems?
System R was designed and developed from 1974 to 1979 at IBM San Jose
Research Centre. System R is the first implementation of SQL, which is the
standard relational data query language, and it was also the first to demonstrate
that RDBMS could provide better transaction processing performance. It is a
prototype which is formed to show that it is possible to build a Relational System
that can be used in a real-life environment to solve real-life problems.

Following are two major subsystems of System R:

○ Research Storage
○ System Relational Data System

38) What is Data Independence?


Data independence specifies that "the application is independent of the storage
structure and access strategy of data." It makes you able to modify the schema
definition at one level without altering the schema definition in the next higher
level.

It makes you able to modify the schema definition in one level should not affect
the schema definition in the next higher level.

There are two types of Data Independence:

Physical Data Independence: Physical data is the data stored in the database. It is
in the bit-format. Modification in physical level should not affect the logical level.

For example: If we want to manipulate the data inside any table that should not
change the format of the table.

Logical Data Independence: Logical data in the data about the database. It
basically defines the structure. Such as tables stored in the database.
Modification in logical level should not affect the view level.

For example: If we need to modify the format of any table, that modification
should not affect the data inside it.
NOTE: Logical Data Independence is more difficult to achieve.

39) What are the three levels of data abstraction?


Following are three levels of data abstraction:

Physical level: It is the lowest level of abstraction. It describes how data are stored.

Logical level: It is the next higher level of abstraction. It describes what data are
stored in the database and what relationship among those data.

View level: It is the highest level of data abstraction. It describes only part of the
entire database.

For example- User interact with the system using the GUI and fill the required
details, but the user doesn't have any idea how the data is being used. So, the
abstraction level is absolutely high in VIEW LEVEL.

Then, the next level is for PROGRAMMERS as in this level the fields and records
are visible and the programmer has the knowledge of this layer. So, the level of
abstraction here is a little low in VIEW LEVEL.

And lastly, physical level in which storage blocks are described.

40) What is Join?


The Join operation is one of the most useful activities in relational algebra. It is
most commonly used way to combine information from two or more relations. A
Join is always performed on the basis of the same or related column. Most
complex queries of SQL involve JOIN command.

There are following types of join:

○ Inner joins: Inner join is of 3 categories. They are:

○ Theta join
○ Natural join
○ Equi join

○ Outer joins: Outer join have three types. They are:

○ Left outer join


○ Right outer join
○ Full outer join

41) What is 1NF?


1NF is the First Normal Form. It is the simplest type of normalization that you can
implement in a database. The primary objectives of 1NF are to:

○ Every column must have atomic (single value)


○ To Remove duplicate columns from the same table
○ Create separate tables for each group of related data and identify each
row with a unique column

42) What is 2NF?


2NF is the Second Normal Form. A table is said to be 2NF if it follows the following
conditions:

○ The table is in 1NF, i.e., firstly it is necessary that the table should follow
the rules of 1NF.
○ Every non-prime attribute is fully functionally dependent on the
primary key, i.e., every non-key attribute should be dependent on the
primary key in such a way that if any key element is deleted, then even
the non_key element will still be saved in the database.

43) What is 3NF?


3NF stands for Third Normal Form. A database is called in 3NF if it satisfies the
following conditions:

○ It is in second normal form.


○ There is no transitive functional dependency.
○ For example: X->Z

Where:
X->Y
Y does not -> X
Y->Z so, X->Z

44) What is BCNF?


BCMF stands for Boyce-Codd Normal Form. It is an advanced version of 3NF, so it
is also referred to as 3.5NF. BCNF is stricter than 3NF.

A table complies with BCNF if it satisfies the following conditions:

○ It is in 3NF.
○ For every functional dependency X->Y, X should be the super key of the
table. It merely means that X cannot be a non-prime attribute if Y is a
prime attribute.

45) Explain ACID properties


ACID properties are some basic rules, which has to be satisfied by every
transaction to preserve the integrity. These properties and rules are:

ATOMICITY: Atomicity is more generally known as ?all or nothing rule.' Which


implies all are considered as one unit, and they either run to completion or not
executed at all.

CONSISTENCY: This property refers to the uniformity of the data. Consistency


implies that the database is consistent before and after the transaction.
ISOLATION: This property states that the number of the transaction can be
executed concurrently without leading to the inconsistency of the database
state.

DURABILITY: This property ensures that once the transaction is committed it will
be stored in the non-volatile memory and system crash can also not affect it
anymore.

46) What is stored procedure?


A stored procedure is a group of SQL statements that have been created and
stored in the database. The stored procedure increases the reusability as here the
code or the procedure is stored into the system and used again and again that
makes the work easy, takes less time in processing and decreases the complexity
of the system. So, if you have a code which you need to use again and again then
save that code and call that code whenever it is required.

47) What is the difference between a DELETE command and


TRUNCATE command?
DELETE command: DELETE command is used to delete rows from a table based
on the condition that we provide in a WHERE clause.

○ DELETE command delete only those rows which are specified with the
WHERE clause.
○ DELETE command can be rolled back.
○ DELETE command maintain a log, that's why it is slow.
○ DELETE use row lock while performing DELETE function.

TRUNCATE command: TRUNCATE command is used to remove all rows


(complete data) from a table. It is similar to the DELETE command with no
WHERE clause.

○ The TRUNCATE command removes all the rows from the table.
○ The TRUNCATE command cannot be rolled back.
○ The TRUNCATE command doesn't maintain a log. That's why it is fast.
○ TRUNCATE use table log while performing the TRUNCATE function.

48) What is 2-Tier architecture?


The 2-Tier architecture is the same as basic client-server. In the two-tier
architecture, applications on the client end can directly communicate with the
database at the server side.

49) What is the 3-Tier architecture?


The 3-Tier architecture contains another layer between the client and server.
Introduction of 3-tier architecture is for the ease of the users as it provides the
GUI, which, make the system secure and much more accessible. In this
architecture, the application on the client-end interacts with an application on
the server which further communicates with the database system.
50) How do you communicate with an RDBMS?
You have to use Structured Query Language (SQL) to communicate with the
RDBMS. Using queries of SQL, we can give the input to the database and then
after processing of the queries database will provide us the required output.

51) What is the difference between a shared lock and exclusive


lock?
Shared lock: Shared lock is required for reading a data item. In the shared lock,
many transactions may hold a lock on the same data item. When more than one
transaction is allowed to read the data items then that is known as the shared
lock.
Exclusive lock: When any transaction is about to perform the write operation,
then the lock on the data item is an exclusive lock. Because, if we allow more
than one transaction then that will lead to the inconsistency in the database.

52) Describe the types of keys?


There are following types of keys:

Primary key: The Primary key is an attribute in a table that can uniquely identify
each record in a table. It is compulsory for every table.

Candidate key: The Candidate key is an attribute or set of an attribute which can
uniquely identify a tuple. The Primary key can be selected from these attributes.

Super key: The Super key is a set of attributes which can uniquely identify a tuple.
Super key is a superset of the candidate key.

Foreign key: The Foreign key is a primary key from one table, which has a
relationship with another table. It acts as a cross-reference between tables.

Operating System Questions


A list of top frequently asked Operating System interview questions and answers are given
below.

1) What is an operating system?


The operating system is a software program that facilitates computer hardware
to communicate and operate with the computer software. It is the most
important part of a computer system without it computer is just like a box.

2) What is the main purpose of an operating system?


There are two main purposes of an operating system:
○ It is designed to make sure that a computer system performs well by
managing its computational activities.
○ It provides an environment for the development and execution of
programs.

3) What are the different operating systems?


○ Batched operating systems
○ Distributed operating systems
○ Timesharing operating systems
○ Multi-programmed operating systems
○ Real-time operating systems

4) What is a socket?
A socket is used to make connection between two applications. Endpoints of the
connection are called socket.

5) What is a real-time system?


Real-time system is used in the case when rigid-time requirements have been
placed on the operation of a processor. It contains a well defined and fixed time
constraints.

6) What is kernel?
Kernel is the core and most important part of a computer operating system
which provides basic services for all parts of the OS.

7) What is monolithic kernel?


A monolithic kernel is a kernel which includes all operating system code is in
single executable image.

8) What do you mean by a process?


An executing program is known as process. There are two types of processes:

○ Operating System Processes


○ User Processes

9) What are the different states of a process?


A list of different states of process:

○ New Process
○ Running Process
○ Waiting Process
○ Ready Process
○ Terminated Process

10) What is the difference between micro kernel and macro


kernel?
Micro kernel: micro kernel is the kernel which runs minimal performance
affecting services for operating system. In micro kernel operating system all other
operations are performed by processor.

Macro Kernel: Macro Kernel is a combination of micro and monolithic kernel.

11) What is the concept of reentrancy?


It is a very useful memory saving technique that is used for multi-programmed
time sharing systems. It provides functionality that multiple users can share a
single copy of program during the same period.
It has two key aspects:

○ The program code cannot modify itself.


○ The local data for each user process must be stored separately.

12) What is the difference between process and program?


A program while running or executing is known as a process.

13) What is the use of paging in operating system?


Paging is used to solve the external fragmentation problem in operating system.
This technique ensures that the data you need is available as quickly as possible.

14) What is the concept of demand paging?


Demand paging specifies that if an area of memory is not currently being used, it
is swapped to disk to make room for an application's need.

15) What is the advantage of a multiprocessor system?


As many as processors are increased, you will get the considerable increment in
throughput. It is cost effective also because they can share resources. So, the
overall reliability increases.

16) What is virtual memory?


Virtual memory is a very useful memory management technique which enables
processes to execute outside of memory. This technique is especially used when
an executing program cannot fit in the physical memory.

17) What is thrashing?


Thrashing is a phenomenon in virtual memory scheme when the processor
spends most of its time in swapping pages, rather than executing instructions.

18) What are the four necessary and sufficient conditions


behind the deadlock?
These are the 4 conditions:

1) Mutual Exclusion Condition: It specifies that the resources involved are


non-sharable.

2) Hold and Wait Condition: It specifies that there must be a process that is
holding a resource already allocated to it while waiting for additional resource
that are currently being held by other processes.

3) No-Preemptive Condition: Resources cannot be taken away while they are


being used by processes.

4) Circular Wait Condition: It is an explanation of the second condition. It specifies


that the processes in the system form a circular list or a chain where each
process in the chain is waiting for a resource held by next process in the chain.

19) What is a thread?


A thread is a basic unit of CPU utilization. It consists of a thread ID, program
counter, register set and a stack.

20) What is FCFS?


FCFS stands for First Come, First Served. It is a type of scheduling algorithm. In
this scheme, if a process requests the CPU first, it is allocated to the CPU first. Its
implementation is managed by a FIFO queue.

21) What is SMP?


SMP stands for Symmetric MultiProcessing. It is the most common type of
multiple processor system. In SMP, each processor runs an identical copy of the
operating system, and these copies communicate with one another when
required.

22) What is RAID? What are the different RAID levels?


RAID stands for Redundant Array of Independent Disks. It is used to store the
same data redundantly to improve the overall performance.

Following are the different RAID levels:

RAID 0 - Stripped Disk Array without fault tolerance

RAID 1 - Mirroring and duplexing

RAID 2 - Memory-style error-correcting codes

RAID 3 - Bit-interleaved Parity

RAID 4 - Block-interleaved Parity

RAID 5 - Block-interleaved distributed Parity

RAID 6 - P+Q Redundancy

23) What is deadlock? Explain.


Deadlock is a specific situation or condition where two processes are waiting for
each other to complete so that they can start. But this situation causes hang for
both of them.

24) Which are the necessary conditions to achieve a


deadlock?
There are 4 necessary conditions to achieve a deadlock:

○ Mutual Exclusion: At least one resource must be held in a non-sharable


mode. If any other process requests this resource, then that process
must wait for the resource to be released.
○ Hold and Wait: A process must be simultaneously holding at least one
resource and waiting for at least one resource that is currently being
held by some other process.
○ No preemption: Once a process is holding a resource ( i.e. once its
request has been granted ), then that resource cannot be taken away
from that process until the process voluntarily releases it.
○ Circular Wait: A set of processes { P0, P1, P2, . . ., PN } must exist such that
every P[ i ] is waiting for P[ ( i + 1 ) % ( N + 1 ) ].

Note: This condition implies the hold-and-wait condition, but it is easier to deal
with the conditions if the four are considered separately.

25) What is Banker's algorithm?


Banker's algorithm is used to avoid deadlock. It is the one of deadlock-avoidance
method. It is named as Banker's algorithm on the banking system where bank
never allocates available cash in such a manner that it can no longer satisfy the
requirements of all of its customers.

26) What is the difference between logical address space and


physical address space?
Logical address space specifies the address that is generated by CPU. On the
other hand physical address space specifies the address that is seen by the
memory unit.

27) What is fragmentation?


Fragmentation is a phenomenon of memory wastage. It reduces the capacity
and performance because space is used inefficiently.
28) How many types of fragmentation occur in Operating
System?
There are two types of fragmentation:

○ Internal fragmentation: It is occurred when we deal with the systems


that have fixed size allocation units.
○ External fragmentation: It is occurred when we deal with systems that
have variable-size allocation units.

29) What is spooling?


Spooling is a process in which data is temporarily gathered to be used and
executed by a device, program or the system. It is associated with printing. When
different applications send output to the printer at the same time, spooling
keeps these all jobs into a disk file and queues them accordingly to the printer.

30) What is the difference between internal commands and


external commands?
Internal commands are the built-in part of the operating system while external
commands are the separate file programs that are stored in a separate folder or
directory.

31) What is semaphore?


Semaphore is a protected variable or abstract data type that is used to lock the
resource being used. The value of the semaphore indicates the status of a
common resource.

There are two types of semaphore:

○ Binary semaphores
○ Counting semaphores
32) What is a binary Semaphore?
Binary semaphore takes only 0 and 1 as value and used to implement mutual
exclusion and synchronize concurrent processes.

33) What is Belady's Anomaly?


Belady's Anomaly is also called FIFO anomaly. Usually, on increasing the number
of frames allocated to a process virtual memory, the process execution is faster,
because fewer page faults occur. Sometimes, the reverse happens, i.e., the
execution time increases even when more frames are allocated to the process.
This is Belady's Anomaly. This is true for certain page reference patterns.

34) What is starvation in Operating System?


Starvation is Resource management problem. In this problem, a waiting process
does not get the resources it needs for a long time because the resources are
being allocated to other processes.

35) What is aging in Operating System?


Aging is a technique used to avoid the starvation in resource scheduling system.

36) What are the advantages of multithreaded programming?


A list of advantages of multithreaded programming:

○ Enhance the responsiveness to the users.


○ Resource sharing within the process.
○ Economical
○ Completely utilize the multiprocessing architecture.

37) What is the difference between logical and physical


address space?
Logical address specifies the address which is generated by the CPU whereas
physical address specifies to the address which is seen by the memory unit.

After fragmentation

38) What are overlays?


Overlays makes a process to be larger than the amount of memory allocated to it.
It ensures that only important instructions and data at any given time are kept in
memory.

39) When does trashing occur?


Thrashing specifies an instance of high paging activity. This happens when it is
spending more time paging instead of executing.

40) What is a Batch Operating System?


Batch Operating System is a type of Operating System which creates Batches for
the execution of certain jobs or processes.

The Batches contains jobs of such a kind that the jobs or processes which are
very similar in the procedure to be followed by the jobs or processes. The Batch
Operating System has an operator which performs these tasks.

An operator groups together comparable jobs or processes that have the same
criteria into batches. The operator is in charge and takes up the job of grouping
jobs or processes with comparable requirements.

Batch Operating System follows First Come First Serve principle.

41) Do the Batch Operating System interact with Computer for


processing the needs of jobs or processes required?
No, this is not that kind of Operating Systems which tries to interact with the
computer. But, this job is taken up by the Operator present in the Batch
Operating Systems.
42) What are the advantages of Batch Operating System?
Advantages of Batch Operating System:

1. The time which the Operating System is at rest is very small or also known as Idle
Time for the Operating System is very small.
2. Very big tasks can also be managed very easily with the help of Batch Operating
Systems
3. Many users can use this Batch Operating Systems.
4. It is incredibly challenging to estimate or determine how long it will take to finish
any task. The batch system processors are aware of how long a work will take to
complete when it is in line.

43) What are the disadvantages of Batch Operating System?


Disadvantages of Batch Operating System:

1. If any work fails in the Batch Operating System, the other jobs will have to wait for
an indeterminate period of time.
2. Batch Operating systems are very challenging to debug,
3. Batch Operating Systems can be expensive at times
4. The computer operators who are using Batch Operating Systems must to be
knowledgeable with batch systems.

44) Where is Batch Operating System used in Real Life


They are used in Payroll System and for generating Bank Statements.

45) What is the Function of Operating System?


The most important functions of Operating Systems are:

1. File Management
2. Job Management
3. Process Management
4. Device Management
5. Memory Management
46) What are the Services provided by the Operating System?
The services provided by the Operating Systems are:

1. Security to your computer


2. Protects your computer from external threats
3. File Management
4. Program Execution
5. Helps in Controlling Input Output Devices
6. Useful in Program Creation
7. Helpful in Error Detection
8. Operating System helps in communicating between devices
9. Analyzes the Performance of all devices

47) What is a System Call in Operating Systems?


Programs can communicate with the operating system by making a system call.
When a computer application requests anything from the kernel of the
operating system, it performs a system call.System call uses Application
Programming Interfaces(API)to deliver operating system services to user
programs

48) What are the Types of System Calls in Operating Systems?


The System Calls in Operating Systems are:

1. Communication
2. Information Maintenance
3. File Management
4. Device Management
5. Process Contro

49) What are the functions which are present in the Process
Control and File Management System Call?
The Functions present in Process Control System Calls are:
1. Create
2. Allocate
3. Abort
4. End
5. Terminate
6. Free Memory

50) What are the functions which are present in the File
Management System Call?
The Functions present in File Management System Calls are:

1. Create
2. Open
3. Read
4. Close
5. Delete

51) What is a Process in Operating Systems?


A process is essentially software that is being run on the Operating System. The
Process is a Procedure which must be carried out in a sequential manner.

The fundamental unit of work that has to be implemented in the system is called
a process.

An active program known as a process is the basis of all computing. Although


relatively similar, the method is not the same as computer code. A process is a
"active" entity, in contrast to the program, which is sometimes thought of as
some sort of "passive" entity.

52) What are the types of Processes in Operating Systems?


The types of Operating System processes are:

1. Operating System Process


2. User Process
53) What is Process Control Block (PCB)?
A data structure called a Process Control Block houses details about the
processes connected to it. The term "process control block" can also refer to a
"task control block," "process table entry," etc.

As data structure for processes is done in terms of the Process Control Block
(PCB), it is crucial for process management. Additionally, it describes the
operating system's present condition.

54) What are the Data Items in Process Control Block?


The Data Items in Process Control Block are:

1. Process State
2. Process Number
3. Program Counter
4. Registers
5. Memory Limits
6. List of Open Files

55) What are the Files used in the Process Control Block?
The Files used in Process Control Block are:

1. Central Processing Unit (CPU) Scheduling Information


2. Memory Management Information
3. Accounting Information
4. Input Output Status Information

56) What are the differences between Thread and Process


Thread Process

Threads are executed within the Processes are executed in the


same process different memory spaces
Threads are not independent of Processes are independent of each
each other other

57) What are the advantages of Threads in Operating


Systems?
The advantages of Threads in Operating System are:

1. Threads are executed very faster than Switches


2. Threads ensure that the communication between threads are very easier
3. The Throughput of the system is increased if the process is divided into multiple
threads
4. When a thread in a multi-threaded process completes its execution, its output
can be returned right away.

58) What are the disadvantages of Threads in Operating


Systems?
The disadvantages of Threads in Operating System are:

1. The code becomes more challenging to maintain and debug as there are more
threads.
2. The process of creating threads uses up system resources like memory and CPU.
3. Because unhandled exceptions might cause the application to crash, we must
manage them inside the worker method.

59) What are the types of Threads in Operating System?


The types of Threads in Operating System are:

1. User Level Threads


2. Kernel Level Threads

60) What is User Kernel Thread?


The kernel is unaware of the user-level threads since they are implemented at
the user level.

They are treated like single-threaded processes under this system. User Kernel
Threads are smaller and quicker than kernel-level threads

The User Kernel Threads are represented by a Small Process Control Block (PCB),
Stack, Program Counter (PC), Stack.

Here, the User Kernel Threads are independent of Kernel Involvement in


Synchronization.

61) What are User Kernel Threads Advantages and


Disadvantages?
The following are a few advantages of User Kernel Threads:

1. Creating user-level threads is quicker and simpler than creating kernel-level


threads. They are also simpler to handle.
2. Any operating system may be used to execute user-level threads.
3. Thread switching in user-level threads does not need kernel mode privileges.

The following are a few drawbacks of User Kernel Threads:

1. Multiprocessing cannot be used effectively by multithreaded applications in


user-level threads.
2. If one user-level thread engages in a blocking action, the entire process is halted.

62) What is Kernel Level Thread?


Kernel Level Threads are the threads which are handled by the Operating System
directly. The kernel controls both the process's threads and the context
information for each one. As a result, kernel-level threads execute more slowly
than user-level threads.

63) What are Kernel Level Threads Advantages and


Disadvantages?
The following are some benefits of using kernel-level threads:

1. Kernel-level threads allow the scheduling of many instances of the same process
across several CPUs.
2. The kernel functions also support multithreading.
3. Another thread of the same process may be scheduled by the kernel if a
kernel-level thread is stalled.

The following list includes several drawbacks of kernel-level threads:

1. To pass control from one thread in a process to another, a mode switch to kernel
mode is necessary.
2. Compared to user-level threads, kernel-level threads take longer to create and
maintain.

64) What is Process Scheduling In Operating Systems?


The task of the process manager that deals with removing the active process
from the CPU and choosing a different process based on a certain strategy is
known as process scheduling.

An integral component of a multiprogramming operating system is process


scheduling. Such operating systems provide the simultaneous loading of
numerous processes into the executable memory, each of which utilizes
temporal multiplexing to share the CPU.

65) What are types of Process Scheduling Techniques in


Operating Systems?
The types of Process Scheduling Techniques in Operating Systems are:

1. Pre Emptive Process Scheduling


2. Non Pre Emptive Process Scheduling

66) What is Pre Emptive Process Scheduling in Operating


Systems?
In this instance of Pre Emptive Process Scheduling, the OS allots the resources to
a process for a predetermined period of time. The process transitions from
running state to ready state or from waiting state to ready state during resource
allocation. This switching happens because the CPU may assign other processes
precedence and substitute the currently active process for the higher priority
process.

67) What is Non Pre Emptive Process Scheduling in Operating


Systems?
In this case of Non Pre Emptive Process Scheduling, the resource cannot be
withdrawn from a process before the process has finished running. When a
running process finishes and transitions to the waiting state, resources are
switched.

68) What is Context Switching?


Context switching is a technique or approach that the operating system use to
move a process from one state to another so that it can carry out its intended
function using system CPUs.

When a system performs a switch, it maintains the status of the previous


operating process in the form of registers and allots the CPU to the new process
to carry out its operations.

The old process must wait in a ready queue while a new one is running in the
system. At the point when another process interrupted it, the old process
resumes execution.

It outlines the features of an operating system that supports numerous


workloads at once without the use of extra processors by allowing several
processes to share a single CPU.

69) What is the use of Dispatcher in Operating Systems?


After the scheduler completes the process scheduling, a unique application
called a dispatcher enters the picture. The dispatcher is the one who moves a
process to the desired state or queue once the scheduler has finished its
selection task. The module known as the dispatcher is what grants a process
control over the CPU once the short-term schedule has chosen it.

70) What is the Difference between Dispatcher and


Scheduler?
Dispatcher Scheduler

Dispatcher is the one who moves Scheduler is the one which selects a
the process to the desired state process which is feasible to be
executed at this point of time.

The time taken by Dispatcher is The Time taken by the Scheduler is


known as Dispatch Latency not counted basically

Dispatcher is dependent on Scheduler is not dependent of


Scheduler Dispatcher

Dispatcher allows Context Switching Scheduler only allows the process to


to occur the ready queue

71) What is Process Synchronization in Operating Systems?


Process synchronization, often known as synchronization, is the method an
operating system uses to manage processes that share the same memory space.
By limiting the number of processes that may modify the shared memory at
once via hardware or variables, it helps ensure the consistency of the data.

72) What are the Classical Problems of Process


Synchronization?
The Classical Problems of Process Synchronization are:
1. Bound Buffer Problem or Consumer Producer Problem
2. Dining Philosopher's Problem
3. Readers and writers Problem
4. Sleeping Barber Problem

73) What is a Peterson's Solution?


Peterson's solution to the critical section issue is a traditional one. The critical
section problem makes sure no two processes or jobsalter or modify the value of
a resource at the same time.

74) What are the Operations in Semaphores?


The Operations in Semaphores are:

1. Wait or P Function ()
2. Signal or V Function ()

75) What is a Critical Section Problem?


The section of a program known as the Critical Section attempts to access shared
resources.

The operating system has trouble authorizing and preventing processes from
entering the crucial part because more than one process cannot operate in the
critical area at once.

76) What are the methods of Handling Deadlocks?


The methods of handling deadlock are:

1. Deadlock Prevention
2. Deadlock Detection and Recovery
3. Deadlock Avoidance
4. Deadlock Ignorance
77) How can we avoid Deadlock?
We can avoid Deadlock by using Banker's Algorithm.

78) How can we detect and recover the Deadlock occurred in


Operating System?
First, what we need to do is to allow the process to enter the deadlock state. So, it
is the time of recovery.

We can recover the process from deadlock state by terminating or aborting all
deadlocked processes one at a time.

Process Pre Emption is also another technique used for Deadlocked Process
Recovery.

79) What is paging in Operating Systems?


Paging is a storage mechanism. Paging is used to retrieve processes from
secondary memory to primary memory.

The main memory is divided into small blocks called pages. Now, each of the
pages contains the process which is retrieved into main memory and it is stored
in one frame of memory.

It is very important to have pages and frames which are of equal sizes which are
very useful for mapping and complete utilization of memory.

80) What is Address Translation in Paging?


Logical and physical memory addresses, both of which are distinct, are the two
types of memory addresses that are employed in the paging process. The logical
address is the address that the CPU creates for each page in the secondary
memory, but the physical address is the actual location of the frame where each
page will be allocated. We now require a technique known as address translation
carried out by the page table in order to translate this logical address into a
physical address.
81) What is Translational Look Aside Buffer?
Whenever logical address is created by the Central Processing Unit (CPU), the
page number is stored in the Translational Look Aside Buffer. Along, with the
page number, the frame number is also stored.

82) What are Page Replacement Algorithms in Operating


Systems?
The Page Replacement Algorithms in Operating Systems are:

1. First In First Out


2. Optimal
3. Least Recently Used
4. Most Recently Used

83) In which Page Replacement Algorithm does Belady's


Anomaly occur?
In First in First out Page Replacement Algorithm Belady's Anomaly occurs.

84) What are Process Scheduling Algorithms in Operating


System?
The Process Scheduling Algorithms in Operating Systems are:

1. First Come First Serve CPU Scheduling Algorithm


2. Priority Scheduling CPU Scheduling Algorithm
3. Shortest Job First CPU Scheduling Algorithm
4. Round Robin CPU Scheduling Algorithm
5. Longest Job First CPU Scheduling Algorithm
6. Shortest Remaining Time First CPU Scheduling Algorithm
7. Multiple Queue CPU Scheduling Algorithm

85) What is Round Robin CPU Scheduling Algorithm?


Round Robin is a CPU scheduling mechanism whose cycles around assigning
each task a specific time slot. It is the First come First Serve CPU Scheduling
method prior Pre Emptive Process Scheduling approach. The Round Robin CPU
algorithm frequently emphasizes the Time Sharing method.

86) What is Disk Scheduling in Operating Systems?


Operating systems use disk scheduling to plan when Input or Output requests
for the disk will arrive. Input or Output scheduling is another name for disk
scheduling.

87) What is the importance of Disk Scheduling in Operating


Systems?
1. One Input or Output request may be fulfilled by the disk controller at a time, even
if several Input or Output requests could come in from other processes. Other
Input or Output requests must thus be scheduled and made to wait in the
waiting queue.
2. The movement of the disk arm might increase if two or more requests are placed
far apart from one another.
3. Since hard disks are among the slower components of the computer system, they
must be accessible quickly.

88) What are the Disk Scheduling Algorithms used in


Operating Systems?
The Disk Scheduling Algorithms used in Operating Systems are:

1. First Come First Serve


2. Shortest Seek Time First
3. LOOK
4. SCAN
5. C SCAN
6. C LOOK

89) What is Monitors in the context of Operating Systems?


A feature of programming languages called monitors and ithelps in
controlledaccess to shared data. The Monitor is a collection of shared actions,
data structures, and synchronization between parallel procedure calls. A monitor
is therefore sometimes referred to as a synchronization tool. Some of the
languages that support the usage of monitors are Java, C#, Visual Basic, Ada, and
concurrent Euclid. Although other processes cannot access the monitor's internal
variables, they can invoke its methods

Networking Interview Questions


A list of top frequently asked Networking interview questions and answers are given below.

1) What is the network?


○ A network is a set of devices that are connected with a physical media
link. In a network, two or more nodes are connected by a physical link or
two or more networks are connected by one or more nodes.
○ A network is a collection of devices connected to each other to allow
the sharing of data.
○ Example of a network is an internet. An internet connects the millions
of people across the world.

AD

2) What do you mean by network topology?


Network topology specifies the layout of a computer network. It shows how
devices and cables are connected to each other. The types of topologies are:

Bus:
○ Bus topology is a network topology in which all the nodes are
connected to a single cable known as a central cable or bus.
○ It acts as a shared communication medium, i.e., if any device wants to
send the data to other devices, then it will send the data over the bus
which in turn sends the data to all the attached devices.
○ Bus topology is useful for a small number of devices. As if the bus is
damaged then the whole network fails.

AD

Star:

○ Star topology is a network topology in which all the nodes are


connected to a single device known as a central device.
○ Star topology requires more cable compared to other topologies.
Therefore, it is more robust as a failure in one cable will only disconnect
a specific computer connected to this cable.
○ If the central device is damaged, then the whole network fails.
○ Star topology is very easy to install, manage and troubleshoot.
○ Star topology is commonly used in office and home networks.

Ring

○ Ring topology is a network topology in which nodes are exactly


connected to two or more nodes and thus, forming a single continuous
path for the transmission.
○ It does not need any central server to control the connectivity among
the nodes.
○ If the single node is damaged, then the whole network fails.
○ Ring topology is very rarely used as it is expensive, difficult to install and
manage.
○ Examples of Ring topology are SONET network, SDH network, etc.

Mesh
○ Mesh topology is a network topology in which all the nodes are
individually connected to other nodes.
○ It does not need any central switch or hub to control the connectivity
among the nodes.
○ Mesh topology is categorized into two parts:

○ Fully connected mesh topology: In this topology, all the nodes are
connected to each other.
○ Partially connected mesh topology: In this topology, all the nodes
are not connected to each other.

○ It is a robust as a failure in one cable will only disconnect the specified


computer connected to this cable.
○ Mesh topology is rarely used as installation and configuration are
difficult when connectivity gets more.
○ Cabling cost is high as it requires bulk wiring.

Tree

○ Tree topology is a combination of star and bus topology. It is also known


as the expanded star topology.
○ In tree topology, all the star networks are connected to a single bus.
○ Ethernet protocol is used in this topology.
○ In this, the whole network is divided into segments known as star
networks which can be easily maintained. If one segment is damaged,
but there is no effect on other segments.
○ Tree topology depends on the "main bus," and if it breaks, then the
whole network gets damaged.
Hybrid

○ A hybrid topology is a combination of different topologies to form a


resulting topology.
○ If star topology is connected with another star topology, then it remains
star topology. If star topology is connected with different topology, then
it becomes a Hybrid topology.
○ It provides flexibility as it can be implemented in a different network
environment.
○ The weakness of a topology is ignored, and only strength will be taken
into consideration.

3) What are the advantages of Distributed Processing?


A list of advantages of distributed processing:

○ Secure
○ Support Encapsulation
○ Distributed database
○ Faster Problem solving
○ Security through redundancy
○ Collaborative Processing

4) What is the criteria to check the network reliability?


Network reliability: Network reliability means the ability of the network to carry
out the desired operation through a network such as communication through a
network.

Network reliability plays a significant role in the network functionality. The


network monitoring systems and devices are the essential requirements for
making the network reliable.The network monitoring system identifies the
problems that are occurred in the network while the network devices ensure that
data should reach the appropriate destination.

The reliability of a network can be measured by the following factors:


○ Downtime: The downtime is defined as the required time to recover.
○ Failure Frequency: It is the frequency when it fails to work the way it is
intended.
○ Catastrophe: It indicates that the network has been attacked by some
unexpected event such as fire, earthquake.

5) Which are the different factors that affect the security of a


network?
There are mainly two security affecting factors:

○ Unauthorized Access
○ Viruses

6) Which are the different factors that affect the reliability of a


network?
The following factors affect the reliability of a network:

○ Frequency of failure
○ Recovery time of a network after a failure

7) Which are the different factors that affect the performance


of a network?
The following factors affect the performance of a network:

○ Large number of users


○ Transmission medium types
○ Hardware
○ Software
8) What makes a network effective and efficient?
There are mainly two criteria which make a network effective and efficient:

○ Performance: : performance can be measured in many ways like


transmit time and response time.
○ Reliability: reliability is measured by frequency of failure.
○ Robustness: robustness specifies the quality or condition of being
strong and in good condition.
○ Security: It specifies how to protect data from unauthorized access and
viruses.

9) What is bandwidth?
Every signal has a limit of upper range frequency and lower range frequency. The
range of limit of network between its upper and lower frequency is called
bandwidth.

AD

10) What is a node and link?


A network is a connection setup of two or more computers directly connected by
some physical mediums like optical fiber or coaxial cable. This physical medium
of connection is known as a link, and the computers that it is connected are
known as nodes.

11) What is a gateway? Is there any difference between a


gateway and router?
A node that is connected to two or more networks is commonly known as a
gateway. It is also known as a router. It is used to forward messages from one
network to another. Both the gateway and router regulate the traffic in the
network.
Differences between gateway and router:

A router sends the data between two similar networks while gateway sends the
data between two dissimilar networks.

12) What is DNS?


DNS is an acronym stands for Domain Name System.

AD

○ DNS was introduced by Paul Mockapetris and Jon Postel in 1983.


○ It is a naming system for all the resources over the internet which
includes physical nodes and applications. It is used to locate to resource
easily over a network.
○ DNS is an internet which maps the domain names to their associated IP
addresses.
○ Without DNS, users must know the IP address of the web page that you
wanted to access.

Working of DNS:

If you want to visit the website of "javaTpoint", then the user will type
"https://www.javatpoint.com" into the address bar of the web browser. Once the
domain name is entered, then the domain name system will translate the
domain name into the IP address which can be easily interpreted by the
computer. Using the IP address, the computer can locate the web page
requested by the user.

13) What is DNS forwarder?


○ A forwarder is used with DNS server when it receives DNS queries that
cannot be resolved quickly. So it forwards those requests to external
DNS servers for resolution.
○ A DNS server which is configured as a forwarder will behave differently
than the DNS server which is not configured as a forwarder.
○ Following are the ways that the DNS server behaves when it is
configured as a forwarder:
○ When the DNS server receives the query, then it resolves the
query by using a cache.
○ If the DNS server is not able to resolve the query, then it forwards
the query to another DNS server.
○ If the forwarder is not available, then it will try to resolve the query
by using root hint.

14) What is NIC?


○ NIC stands for Network Interface Card. It is a peripheral card attached to
the PC to connect to a network. Every NIC has its own MAC address that
identifies the PC on the network.
○ It provides a wireless connection to a local area network.
○ NICs were mainly used in desktop computers.

15) What is the meaning of 10Base-T?


It is used to specify data transfer rate. In 10Base-T, 10 specify the data transfer rate,
i.e., 10Mbps. The word Base specifies the baseband as opposed to broadband. T
specifies the type of the cable which is a twisted pair.

16) What is NOS in computer networking?


○ NOS stands for Network Operating System. It is specialized software
which is used to provide network connectivity to a computer to make
communication possible with other computers and connected devices.
○ NOS is the software which allows the device to communicate, share files
with other devices.
○ The first network operating system was Novel NetWare released in 1983.
Some other examples of NOS are Windows 2000, Windows XP, Linux,
etc.
17) What are the different types of networks?
Networks can be divided on the basis of area of distribution. For example:

○ PAN (Personal Area Network): Its range limit is up to 10 meters. It is


created for personal use. Generally, personal devices are connected to
this network. For example computers, telephones, fax, printers, etc.
○ LAN (Local Area Network): It is used for a small geographical location
like office, hospital, school, etc.
○ HAN (House Area Network): It is actually a LAN that is used within a
house and used to connect homely devices like personal computers,
phones, printers, etc.
○ CAN (Campus Area Network): It is a connection of devices within a
campus area which links to other departments of the organization
within the same campus.
○ MAN (Metropolitan Area Network): It is used to connect the devices
which span to large cities like metropolitan cities over a wide
geographical area.
○ WAN (Wide Area Network): It is used over a wide geographical location
that may range to connect cities and countries.
○ GAN (Global Area Network): It uses satellites to connect devices over
global are.

18) What is POP3?


POP3 stands for Post Office Protocol version3. POP is responsible for accessing
the mail service on a client machine. POP3 works on two models such as Delete
mode and Keep mode.

19) What do you understand by MAC address?


MAC stands for Media Access Control. It is the address of the device at the Media
Access Control Layer of Network Architecture. It is a unique address means no
two devices can have same MAC addresses.
20) What is IP address?
IP address is a unique 32 bit software address of a computer in a network system.

21) What is private IP address?


There are three ranges of IP addresses that have been reserved for IP addresses.
They are not valid for use on the internet. If you want to access internet on these
private IPs, you must have to use proxy server or NAT server.

22) What is public IP address?


A public IP address is an address taken by the Internet Service Provider which
facilitates you to communication on the internet.

23) What is APIPA?


APIPA is an acronym stands for Automatic Private IP Addressing. This feature is
generally found in Microsoft operating system.

24) What is the full form of ADS?


○ ADS stands for Active Directory Structure.
○ ADS is a microsoft technology used to manage the computers and
other devices.
○ ADS allows the network administrators to manage the domains, users
and objects within the network.
○ ADS consists of three main tiers:

○ Domain: Users that use the same database will be grouped into a
single domain.
○ Tree: Multiple domains can be grouped into a single tree.
○ Forest: Multiple trees can be grouped into a single forest.
25) What is RAID?
RAID is a method to provide Fault Tolerance by using multiple Hard Disc Drives.

26) What is anonymous FTP?


Anonymous FTP is used to grant users access to files in public servers. Users
which are allowed access to data in these servers do not need to identify
themselves, but instead log in as an anonymous guest.

27) What is protocol?


A protocol is a set of rules which is used to govern all the aspects of information
communication.

28) What are the main elements of a protocol?


The main elements of a protocol are:

○ Syntax: It specifies the structure or format of the data. It also specifies


the order in which they are presented.
○ Semantics: It specifies the meaning of each section of bits.
○ Timing: Timing specifies two characteristics: When data should be sent
and how fast it can be sent.

29 What is the Domain Name System?


There are two types of client/server programs. First is directly used by the users
and the second supports application programs.

The Domain Name System is the second type supporting program that is used
by other programs such as to find the IP address of an e-mail recipient.

30) What is link?


A link is connectivity between two devices which includes the cables and
protocols used in order to make communication between devices.

31) How many layers are in OSI reference model?


OSI reference model: OSI reference model is an ISO standard which defines a
networking framework for implementing the protocols in seven layers. These
seven layers can be grouped into three categories:

○ Network layer: Layer 1, Layer 2 and layer 3 are the network layers.
○ Transport layer: Layer 4 is a transport layer.
○ Application layer. Layer 5, Layer 6 and Layer 7 are the application layers.

There are 7 layers in the OSI reference model.

1. Physical Layer

○ It is the lowest layer of the OSI reference model.


○ It is used for the transmission of an unstructured raw bit stream over a
physical medium.
○ Physical layer transmits the data either in the form of electrical/optical
or mechanical form.
○ The physical layer is mainly used for the physical connection between
the devices, and such physical connection can be made by using
twisted-pair cable, fibre-optic or wireless transmission media.

2. DataLink Layer

○ It is used for transferring the data from one node to another node.
○ It receives the data from the network layer and converts the data into
data frames and then attach the physical address to these frames
which are sent to the physical layer.
○ It enables the error-free transfer of data from one node to another node.
Functions of Data-link layer:
○ Frame synchronization: Data-link layer converts the data into frames,
and it ensures that the destination must recognize the starting and
ending of each frame.
○ Flow control: Data-link layer controls the data flow within the network.
○ Error control: It detects and corrects the error occurred during the
transmission from source to destination.
○ Addressing: Data-link layer attach the physical address with the data
frames so that the individual machines can be easily identified.
○ Link management: Data-link layer manages the initiation, maintenance
and, termination of the link between the source and destination for the
effective exchange of data.

3. Network Layer

○ Network layer converts the logical address into the physical address.
○ It provides the routing concept means it determines the best route for
the packet to travel from source to the destination.
Functions of network layer:
○ Routing: The network layer determines the best route from source to
destination. This function is known as routing.
○ Logical addressing: The network layer defines the addressing scheme to
identify each device uniquely.
○ Packetizing: The network layer receives the data from the upper layer
and converts the data into packets. This process is known as
packetizing.
○ Internetworking: The network layer provides the logical connection
between the different types of networks for forming a bigger network.
○ Fragmentation: It is a process of dividing the packets into the
fragments.

4. Transport Layer

○ It delivers the message through the network and provides error


checking so that no error occurs during the transfer of data.
○ It provides two kinds of services:

○ Connection-oriented transmission: In this transmission, the


receiver sends the acknowledgement to the sender after the
packet has been received.
○ Connectionless transmission: In this transmission, the receiver
does not send the acknowledgement to the sender.
5. Session Layer

○ The main responsibility of the session layer is beginning, maintaining


and ending the communication between the devices.
○ Session layer also reports the error coming from the upper layers.
○ Session layer establishes and maintains the session between the two
users.

6. Presentation Layer

○ The presentation layer is also known as a Translation layer as it


translates the data from one format to another format.
○ At the sender side, this layer translates the data format used by the
application layer to the common format and at the receiver side, this
layer translates the common format into a format used by the
application layer.
Functions of presentation layer:

○ Character code translation


○ Data conversion
○ Data compression
○ Data encryption

7. Application Layer

○ Application layer enables the user to access the network.


○ It is the topmost layer of the OSI reference model.
○ Application layer protocols are file transfer protocol, simple mail transfer
protocol, domain name system, etc.
○ The most widely used application protocol is HTTP(Hypertext transfer
protocol ). A user sends the request for the web page using HTTP.

32) What is the usage of OSI physical layer?


The OSI physical layer is used to convert data bits into electrical signals and vice
versa. On this layer, network devices and cable types are considered and setup.
33) Explain the functionality of OSI session layer?
OSI session layer provides the protocols and means for two devices on the
network to communicate with each other by holding a session. This layer is
responsible for setting up the session, managing information exchange during
the session, and tear-down process upon termination of the session.

34) What is the maximum length allowed for a UTP cable?


The maximum length of UTP cable is 90 to 100 meters.

35) What is RIP?


○ RIP stands for Routing Information Protocol. It is accessed by the
routers to send data from one network to another.
○ RIP is a dynamic protocol which is used to find the best route from
source to the destination over a network by using the hop count
algorithm.
○ Routers use this protocol to exchange the network topology
information.
○ This protocol can be used by small or medium-sized networks.

36) What do you understand by TCP/IP?


TCP/IP is short for Transmission Control Protocol /Internet protocol. It is a set of
protocol layers that is designed for exchanging data on different types of
networks.

37) What is netstat?


The "netstat" is a command line utility program. It gives useful information about
the current TCP/IP setting of a connection.

38) What do you understand by ping command?


The "ping" is a utility program that allows you to check the connectivity between
the network devices. You can ping devices using its IP address or name.

39) What is Sneakernet?


Sneakernet is the earliest form of networking where the data is physically
transported using removable media.

40) Explain the peer-peer process.


The processes on each machine that communicate at a given layer are called
peer-peer process.

41) What is a congested switch?


A switch receives packets faster than the shared link. It can accommodate and
stores in its memory, for an extended period of time, then the switch will
eventually run out of buffer space, and some packets will have to be dropped.
This state is called a congested state.

42) What is multiplexing in networking?


In Networking, multiplexing is the set of techniques that is used to allow the
simultaneous transmission of multiple signals across a single data link.

43) What are the advantages of address sharing?


Address sharing provides security benefit instead of routing. That's because host
PCs on the Internet can only see the public IP address of the external interface on
the computer that provides address translation and not the private IP addresses
on the internal network.

44) What is RSA Algorithm?


RSA is short for Rivest-Shamir-Adleman algorithm. It is mostly used for public key
encryption.

45) How many layers are in TCP/IP?


There are basic 4 layers in TCP/IP:

1. Application Layer
2. Transport Layer
3. Internet Layer
4. Network Layer

46) What is the difference between TCP/IP model and the OSI
model?
Following are the differences between the TCP/IP model and OSI model:

TCP/IP model OSI model

Full form of TCP is transmission Full form of OSI is Open System


control protocol. Interconnection.

TCP/IP has 4 layers. OSI has 7 layers.

TCP/IP is more reliable than the OSI OSI model is less reliable as
model. compared to the TCP/IP model.

TCP/IP model uses horizontal OSI model uses vertical approach.


approach.
TCP/IP model uses both session and OSI Reference model uses separate
presentation layer in the application session and presentation layers.
layer.

TCP/IP model developed the OSI model developed the model first
protocols first and then model. and then protocols.

In Network layer, TCP/IP model In the Network layer, the OSI model
supports only connectionless supports both connection-oriented
communication. and connectionless communication.

TCP/IP model is a protocol OSI model is a protocol


dependent. independent.

47) What is the difference between domain and workgroup?

Workgroup Domain

A workgroup is a peer-to-peer A domain is a Client/Server network.


computer network.

A Workgroup can consist of A domain can consist up to 2000


maximum 10 computers. computers.

Every user can manage the There is one administrator to


resources individually on their PCs. administer the domain and its
resources.
All the computers must be on the The computer can be on any
same local area network. network or anywhere in the world.

Each computer must be changed Any change made to the computer


manually. will reflect the changes to all the
computers.

OOPs Interview Questions


A list of top frequently asked OOPs interview questions and answers are given below.

1) What do you understand by OOP?


OOP stands for object-oriented programming. It is a programming paradigm
that revolves around the object rather than function and procedure. In other
words, it is an approach for developing applications that emphasize on objects.
An object is a real word entity that contains data and code. It allows binding data
and code together.

2) Name any seven widely used OOP languages.


There are various OOP languages but the most widely used are:

○ Python
○ Java
○ Go
○ Dart
○ C++
○ C#
○ Ruby

3) What is the purpose of using OOPs concepts?


The aim of OOP is to implement real-world entities like inheritance, hiding,
polymorphism in programming. The main purpose of OOP is to bind together
the data and the functions that operate on them so that no other part of the
code can access this data except that function.

4) What are the four main features of OOPs?


The OOP has the following four features:

○ Inheritance
○ Encapsulation
○ Polymorphism
○ Data Abstraction

5) Why OOP is so popular?


OOPs, programming paradigm is considered as a better style of programming.
Not only it helps in writing a complex piece of code easily, but it also allows users
to handle and maintain them easily as well. Not only that, the main pillar of OOPs
- Data Abstraction, Encapsulation, Inheritance, and Polymorphism, makes it easy
for programmers to solve complex scenarios. As a result of these, OOPs is so
popular.

6) What are the advantages and disadvantages of OOP?


Advantages of OOP

○ It follows a bottom-up approach.


○ It models the real word well.
○ It allows us the reusability of code.
○ Avoids unnecessary data exposure to the user by using the abstraction.
○ OOP forces the designers to have a long and extensive design phase
that results in better design and fewer flaws.
○ Decompose a complex problem into smaller chunks.
○ Programmer are able to reach their goals faster.
○ Minimizes the complexity.
○ Easy redesign and extension of code that does not affect the other
functionality.

Disadvantages of OOP

○ Proper planning is required.


○ Program design is tricky.
○ Programmer should be well skilled.
○ Classes tend to be overly generalized.

7) What are the limitations of OOPs?


○ Requires intensive testing processes.
○ Solving problems takes more time as compared to Procedure Oriented
Programming.
○ The size of the programs created using this approach may become
larger than the programs written using the procedure-oriented
programming approach.
○ Software developed using this approach requires a substantial amount
of pre-work and planning.
○ OOP code is difficult to understand if you do not have the
corresponding class documentation.
○ In certain scenarios, these programs can consume a large amount of
memory.
○ Not suitable for small problems.
○ Takes more time to solve problems.

8) What are the differences between object-oriented


programming and structural programming?

Object-oriented Programming Structural Programming

It follows a bottom-up approach. It follows a top-down approach.

It provides data hiding. Data hiding is not allowed.

It is used to solve complex problems. It is used to solve moderate


problems.

It allows reusability of code that Reusability of code is not allowed.


reduces redundancy of code.

It is based on objects rather than It provides a logical structure to a


functions and procedures. program in which the program is
divided into functions.

It provides more security as it has a It provides less security as it does not


data hiding feature. support the data hiding feature.
More abstraction more flexibility. Less abstraction less flexibility.

It focuses on data. It focuses on the process or logical


structure.

9) What do you understand by pure object-oriented


language? Why Java is not a pure object-oriented
programming language?
The programming language is called pure object-oriented language that treats
everything inside the program as an object. The primitive types are not
supported by the pure OOPs language. There are some other features that must
satisfy by a pure object-oriented language:

○ Encapsulation
○ Inheritance
○ Polymorphism
○ Abstraction
○ All predefined types are objects
○ All user-defined types are objects
○ All operations performed on objects must be only through methods
exposed to the objects.

Java is not a pure object-oriented programming language because pre-defined


data types in Java are not treated as objects. Hence, it is not an object-oriented
language.

10) What do you understand by class and object? Also, give


example.
Class: A class is a blueprint or template of an object. It is a user-defined data type.
Inside a class, we define variables, constants, member functions, and other
functionality. It does not consume memory at run time. Note that classes are not
considered as a data structure. It is a logical entity. It is the best example of data
binding.
Object: An object is a real-world entity that has attributes, behavior, and
properties. It is referred to as an instance of the class. It contains member
functions, variables that we have defined in the class. It occupies space in the
memory. Different objects have different states or attributes, and behaviors.

The following figure best illustrates the class and object.

11) What are the differences between class and object?

Class Object

It is a logical entity. It is a real-world entity.

It is conceptual. It is real.

It binds data and methods together It is just like a variable of a class.


into a single unit.
It does not occupy space in the It occupies space in the memory.
memory.

It is a data type that represents the It is an instance of the class.


blueprint of an object.

It is declared once. Multiple objects can be declared as


and when required.

It uses the keyword class when It uses the new keyword to create an
declared. object.

A class can exist without any object. Objects cannot exist without a class.

12) What are the key differences between class and structure?

Class Structure

Class is a group of common objects The structure is a collection of


that shares common properties. different data types.

It deals with data members and It deals with data members only.
member functions.

It supports inheritance. It does not support inheritance.

Member variables cannot be Member variables can be initialized


initialized directly. directly.
It is of type reference. It is of a type value.

It's members are private by default. It's members are public by default.

The keyword class defines a class. The keyword struct defines a


structure.

An instance of a class is an object. An instance of a structure is a


structure variable.

Useful while dealing with the Useful while dealing with the small
complex data structure. data structure.

13) What is the concept of access specifiers when should we


use these?
In OOPs language, access specifiers are reserved keyword that is used to set the
accessibility of the classes, methods and other members of the class. It is also
known as access modifiers. It includes public, private, and protected. There is
some other access specifier that is language-specific. Such as Java has another
access specifier default. These access specifiers play a vital role in achieving one
of the major functions of OOP, i.e. encapsulation. The following table depicts the
accessibility.
14) What are the manipulators in OOP and how it works?
Manipulators are helping functions. It is used to manipulate or modify the input
or output stream. The modification is possible by using the insertion (<<) and
extraction (>>) operators. Note that the modification of input or output stream
does not mean to change the values of variables. There are two types of
manipulators with arguments or without arguments.

The example of manipulators that do not have arguments is endl, ws, flush, etc.
Manipulators with arguments are setw(val), setfill(c), setbase(val), setiosflags(flag).
Some other manipulators are showpos, fixed, scientific, hex, dec, oct, etc.

15) What are the rules for creating a constructor?


○ It cannot have a return type.
○ It must have the same name as the Class name.
○ It cannot be marked as static.
○ It cannot be marked as abstract.
○ It cannot be overridden.
○ It cannot be final.
16) What are the differences between the constructor and the
method in Java?

Constructor Method

Constructor has the same name as The method name and class name
the class name. are not the same.

It is a special type of method that is It is a set of instructions that can be


used to initialize an object of its invoked at any point in a program.
class.

It creates an instance of a class. It is used to execute Java code.

It is invoked implicitly when we It gets executed when we explicitly


create an object of the class. called it.

It cannot be inherited by the It can be inherited by the subclass.


subclass.

It does not have any return type. It must have a return type.

It cannot be overridden in Java. It can be overridden in Java.

It cannot be declared as static. It can be declared as static.

Java compiler automatically Java compiler does not provide any


provides a default constructor. method by default.
17) How does procedural programming be different from OOP
differ?

Procedural Oriented Object-Oriented Programming


Programming

It is based on functions. It is based on real-world objects.

It follows a top-down approach. It follows a bottom-up approach.

It is less secure because there is no It provides more security.


proper way to hide data.

Data is visible to the whole program. It encapsulates the data.

Reuse of code is not allowed. The code can be reused.

Modification and extension of code We can easily modify and extend


are not easy. code.

Examples of POP are C, VB, Examples of OOPs are C++, Java, C#,
FORTRAN, Pascal, etc. .NET, etc.

18) What are the differences between error and exception?

Basis of Exception Error


Comparison
Recoverable/ Exception can be An error cannot be
Irrecoverable recovered by using the recovered.
try-catch block.

Type It can be classified into two All errors in Java are


categories i.e. checked and unchecked.
unchecked.

Occurrence It occurs at compile time or It occurs at run time.


run time.

Package It belongs to It belongs to


java.lang.Exception java.lang.Error
package. package.

Known or unknown Only checked exceptions Errors will not be


are known to the compiler. known to the
compiler.

Causes It is mainly caused by the It is mostly caused by


application itself. the environment in
which the application
is running.

Example Checked Exceptions: Java.lang.StackOverFlo


SQLException, IOException w,
java.lang.OutOfMemor
Unchecked Exceptions: yError
ArrayIndexOutOfBoundExc
eption,
NullPointerException,
ArithmaticException
19) What are the characteristics of an abstract class?
An abstract class is a class that is declared as abstract. It cannot be instantiated
and is always used as a base class. The characteristics of an abstract class are as
follows:

○ Instantiation of an abstract class is not allowed. It must be inherited.


○ An abstract class can have both abstract and non-abstract methods.
○ An abstract class must have at least one abstract method.
○ You must declare at least one abstract method in the abstract class.
○ It is always public.
○ It is declared using the abstract

The purpose of an abstract class is to provide a common definition of the base


class that multiple derived classes can share.

20) Is it possible for a class to inherit the constructor of its base


class?
No, a class cannot inherit the constructor of its base class.

21) Identify which OOPs concept should be used in the


following scenario?
A group of 5 friends, one boy never gives any contribution when the group goes
for the outing. Suddenly a beautiful girl joins the same group. The boy who never
contributes is now spending a lot of money for the group.

Runtime Polymorphism

22) What is composition?


Composition is one of the vital concepts in OOP. It describes a class that
references one or more objects of other classes in instance variables. It allows us
to model a has-a association between objects. We can find such relationships in
the real world. For example, a car has an engine. the following figure depicts the
same
The main benefits of composition are:

○ Reuse existing code


○ Design clean APIs
○ Change the implementation of a class used in a composition without
adapting any external clients.

23) What are the differences between copy constructor and


assignment operator?
The copy constructor and the assignment operator (=) both are used to initialize
one object using another object. The main difference between the two is that the
copy constructor allocates separate memory to both objects i.e. existing object
and newly created object while the assignment operator does not allocate new
memory for the newly created object. It uses the reference variable that points to
the previous memory block (where an old object is located).

Syntax of Copy Constructor

​ class_name (const class_name &obj)


​ {
​ //body
​ }
Syntax of Assignment Operator
​ class_name obj1, obj2;
​ obj1=obj2;

Copy Constructor Assignment Operator

It is an overloaded constructor. It is an operator.

It creates a new object as a copy of It assigns the value of one object to


an existing object. another object both of which already
exist.

The copy constructor is used when a It is used when we want to assign an


new object is created with some existing object to a new object.
existing object.

Both the objects use separate Both objects share the same
memory locations. memory but use the two different
reference variables that point to the
same location.

If no copy constructor is defined in If the assignment operator is not


the class, the compiler provides one. overloaded then the bitwise copy
will be made.

24) What is the difference between Composition and


Inheritance?
Inheritance means an object inheriting reusable properties of the base class.
Compositions mean that an object holds other objects. In Inheritance, there is
only one object in memory (derived object) whereas, in Composition, the parent
object holds references of all composed objects. From a design perspective,
inheritance is "is a" relationship among objects whereas Composition is "has a"
relationship among objects.
25) What is constructor chaining?
In OOPs, constructor chaining is a sequence of invoking constructors (of the
same class) upon initializing an object. It is used when we want to invoke a
number of constructors, one after another by using only an instance. In other
words, if a class has more than one constructor (overloaded) and one of them
tries to invoke another constructor, this process is known as constructor chaining.
In C++, it is known as constructor delegation and it is present from C++ 11.
26) What are the limitations of inheritance?
○ The main disadvantage of using inheritance is two classes get tightly
coupled. That means one cannot be used independently of the other. If
a method or aggregate is deleted in the Super Class, we have to refactor
using that method in SubClass.
○ Inherited functions work slower compared to normal functions.
○ Need careful implementation otherwise leads to improper solutions.

27) What are the differences between Inheritance and


Polymorphism?

Inheritance Polymorphism
Inheritance is one in which a derived Polymorphism is one that you can
class inherits the already existing define in different forms.
class's features.

It refers to using the structure and It refers to changing the behavior of


behavior of a superclass in a a superclass in the subclass.
subclass.

It is required in order to achieve In order to achieve polymorphism,


polymorphism. inherence is not required.

It is applied to classes. It is applied to functions and


methods.

It can be single, hybrid, multiple, There are two types of


hierarchical, multipath, and polymorphism compile time and
multilevel inheritance. run time.

It supports code reusability and It allows the object to decide which


reduces lines of code. form of the function to be invoked at
run-time (overriding) and
compile-time (overloading).

28) What is Coupling in OOP and why it is helpful?


In programming, separation of concerns is known as coupling. It means that an
object cannot directly change or modify the state or behavior of other objects. It
defines how closely two objects are connected together. There are two types of
coupling, loose coupling, and tight coupling.

Objects that are independent of one another and do not directly modify the state
of other objects is called loosely coupled. Loose coupling makes the code more
flexible, changeable, and easier to work with.
Objects that depend on other objects and can modify the states of other objects
are called tightly coupled. It creates conditions where modifying the code of one
object also requires changing the code of other objects. The reuse of code is
difficult in tight coupling because we cannot separate the code.

Since using loose coupling is always a good habit.

29) Name the operators that cannot be overload.


1. Scope Resolution Operator (::)
2. Ternary Operator (? :)
3. Member Access or Dot Operator (.)
4. Pointer to Member Operator (.*)
5. sizeof operator

30) What is the difference between new and override?


The new modifier instructs the compiler to use the new implementation instead
of the base class function. Whereas, Override modifier helps to override the base
class function.

virtual: indicates that a method may be overridden by an inheritor

override: Overrides the functionality of a virtual method in a base class, providing


different functionality.

new: Hides the original method (which doesn't have to be virtual), providing
different functionality. This should only be used where it is absolutely necessary.

When you hide a method, you can still access the original method by upcasting
to the base class. This is useful in some scenarios, but dangerous.

31) Explain overloading and overriding with example?


Overloading

Overloading is a concept in OOP when two or more methods in a class with the
same name but the method signature is different. It is also known as
compile-time polymorphism. For example, in the following code snippet, the
method add() is an overloaded method.

​ public class Sum


​ {
​ int a, b, c;
​ public int add();
​ {
​ c=a+b;
​ return c;
​ }
​ add(int a, int b);
​ {
​ //logic
​ }
​ add(int a, int b, int c);
​ {
​ //logic
​ }
​ add(double a, double b, double c);
​ {
​ //logic
​ }
​ //statements
​ }
Overriding

If a method with the same method signature is presented in both child and
parent class is known as method overriding. The methods must have the same
number of parameters and the same type of parameter. It overrides the value of
the parent class method. It is also known as runtime polymorphism. For example,
consider the following program.

​ class Dog
​ {
​ public void bark()
​ {
​ System.out.println("woof ");
​ }
​ }
​ class Hound extends Dog
​ {
​ public void sniff()
​ {
​ System.out.println("sniff ");
​ }
​ //overrides the method bark() of the Dog class
​ public void bark()
​ {
​ System.out.println("bowl");
​ }
​ }
​ public class OverridingExample
​ {
​ public static void main(String args[])
​ {
​ Dog dog = new Hound();
​ //invokes the bark() method of the Hound class
​ dog.bark();
​ }
​ }

32) What is Cohesion in OOP?


In OOP, cohesion refers to the degree to which the elements inside a module
belong together. It measures the strength of the relationship between the
module and data. In short, cohesion represents the clarity of the responsibilities
of a module. It is often contrasted with coupling.

It focuses on a how single module or class is intended. Higher the cohesiveness


of the module or class, better is the object-oriented design.
There are two types of cohesion, i.e. High and Low.

○ High cohesion is associated with several required qualities of software


including robustness, reliability, and understandability.
○ Low cohesion is associated with unwanted qualities such as being
difficult to maintain, test, reuse, or even understand.

High cohesion often associates with loose coupling and vice versa.

33) Give a real-world example of polymorphism?


The general meaning of Polymorphism is one that has different forms. The best
real-world example of polymorphism is a person that plays different roles at
different palaces or situations.

○ At home a person can play the role of father, husband, and son.
○ At the office the same person plays the role of boss or employee.
○ In public transport, he plays the role of passenger.
○ In the hospital, he can play the role of doctor or patient.
○ At the shop, he plays the role of customer.

Hence, the same person possesses different behavior in different situations. It is


called polymorphism.

34) What is the difference between a base class and a


superclass?
The base class is the root class- the most generalized class. At the same time, the
superclass is the immediate parent class from which the other class inherits.

35) What is data abstraction and how can we achieve data


abstraction?
It is one of the most important features of OOP. It allows us to show only essential
data or information to the user and hides the implementation details from the
user. A real-world example of abstraction is driving a car. When we drive a car, we
do not need to know how the engine works (implementation) we only know how
ECG works.

There are two ways to achieve data abstraction

○ Abstract class
○ Abstract method
36) What are the levels of data abstraction?
There are three levels of data abstraction:

○ Physical Level: It is the lowest level of data abstraction. It shows how the
data is actually stored in memory.
○ Logical Level: It includes the information that is actually stored in the
database in the form of tables. It also stores the relationship among the
data entities in relatively simple structures. At this level, the information
available to the user at the view level is unknown.
○ View Level: It is the highest level of data abstraction. The actual
database is visible to the user. It exists to ease the availability of the
database by an individual user.

37) What are the types of variables in OOP?


There are three types of variables:
Instance Variable: It is an object-level variable. It should be declared inside a class
but must be outside a method, block, and constructor. It is created when an
object is created by using the new keyword. It can be accessed directly by calling
the variable name inside the class.

Static Variable: It is a class-level variable. It is declared with keyword static inside a


class but must be outside of the method, block, and constructor. It stores in static
memory. Its visibility is the same as the instance variable. The default value of a
static variable is the same as the instance variable. It can be accessed by calling
the class_name.variable_name.

Local Variable: It is a method-level variable. It can be declared in method,


constructor, or block. Note that the use of an access modifier is not allowed with
local variables. It is visible only to the method, block, and constructor in which it is
declared. Internally, it is implemented at the stack level. It must be declared and
initialized before use.

Another type of variable is used in object-oriented programming is the reference


variable.

Reference Variable: It is a variable that points to an object of the class. It points to


the location of the object that is stored in the memory.
38) Is it possible to overload a constructor?
Yes, the constructors can be overloaded by changing the number of arguments
accepted by the constructor or by changing the data type of the parameters. For
example:

​ public class Demo


​ {
​ Demo()
​ {
​ //logic
​ }
​ Demo(String str) //overloaded constructor
​ {
​ //logic
​ }
​ Demo(double d) //overloaded constructor
​ {
​ //logic
​ }
​ //statements
​ }

39) Can we overload the main() method in Java also give an


example?
Yes, we can also overload the main() method in Java. Any number of main()
methods can be defined in the class, but the method signature must be
different. Consider the following code.

​ class OverloadMain
​ {
​ public static void main(int a) //overloaded main method
​ {
​ System.out.println(a);
​ }
​ public static void main(String args[])
​ {
​ System.out.println("main method invoked");
​ main(6);
​ }
​ }

40) Consider the following scenario:


If a class Demo has a static block and a main() method. A print statement is
presented in both. The question is which one will first execute, static block or the
main() method, and why?

JVM first executes the static block on a priority basis. It means JVM first goes to
static block even before it looks for the main() method in the program. After that
main() method will be executed.

​ class Demo
​ {
​ static //static block
​ {
​ System.out.println("Static block");
​ }
​ public static void main(String args[]) //static method
​ {
​ System.out.println("Static method");
​ }
​ }

You might also like