B. Tech OOPs Test Questions 2023-24
B. Tech OOPs Test Questions 2023-24
Printed Pages:
Session: 2023-24
Semester:
Course Code: Roll No.:
Course Name: Time: 1.15 Hrs.
Maximum Marks:
Instructions:
1. Attempt All sections.
2. If require any missing data, then choose suitably.
1 What are the main differences between procedure-oriented languages and object-oriented 5 CO1
languages?
2 What are the basic OOPs principles? 5 CO1
3 Difference between Top down and bottom up approaches for a given project? 5 CO1
7 Using diagrams, explain the following concepts as applied in Object Oriented Analysis and 5 CO1
Design. Object, class, polymorphism, encapsulation and abstraction
8 Explain about object interaction and collaboration? 5 CO1
11
What is the difference between Multilevel and Muliple Inheritance?
12
List the advantage offered by object-oriented systems development.
13
What is an abstract class? Is it possible that an abstract class is inherited by another class?
Ans. An abstract class is a class that is declared abstract-it may or may not include abstract
methods. Abstract classes cannot be instantiated, but they can be subclassed. Yes, we can inherit
abstract class from another abstract class.
17 What do you mean by encapsulation ? How does the object-oriented concept of message
passing help to encapsulate the implementation of an object, including its data?
1. Encapsulation consists of separating the external aspects of an object, which are accessible to
other objects, from the internal implementation details of the object, which are hidden from other
objects.
[Link] prevents a program from becoming so interdependent
that a small change has massive ripple effects.
[Link] implementation of an object can be changed without affecting the applications that use it.
One may want to change the implementation of an object to improve
performance, fix a bug, consolidate code, or for porting.
[Link] understand encapsulation, let us consider the object ‘Employee’.
[Link] attributes of employees say ‘salary’ is kept hidden inside the object and may be made
accessible only through the method meant for the purpose.
[Link] method resides within the object.
For example , if getSalary() is a method of the object ‘Employee’ to get the salary of an employee,
then the salary of an employee can be obtained by no other way but by this method.
[Link] objects can also send messages to the object ‘Employee’ and get the salary of an employee
by the getSalary() method.
9. Other objects need not be concerned with the attributes and internal
structure of the object.
10. This is shown in Fig. 1.9.1. The figure shows that attributes are hidden inside the object by a
method
Using message passing to encapsulate the implementation of an object : Other parts of a system
only see an object’s interface (services it can perform and operation signatures). Internal details
including data are hidden and can only be accessed by a message that contains a valid signature
18 Explain all basic concepts of object oriented programming.
Ans. Features of object-oriented language are:
1. Encapsulation:
i. Encapsulation means that data are encapsulated inside an inviolable shell
along with the methods required to use it.
ii. The only way to reach the data is through these particular methods (see
Fig.).
iii. It is the mechanism that binds together code and the data it manipulates.
iv. This concept is also used to hide the internal representation, or state, of an
object from the outside.
2. Polymorphism:
i. Polymorphism means having many forms.
ii. Polymorphism is the ability of a message to be displayed in more than one
form.
iii. lt plays an important role in allowing objects having different internal
structure to share the same external interface.
3. Inheritance:
i. Inheritance is the ability to create classes that share the attributes and
methods of existing classes, but with more specific features.
19 What are the principles of modeling ? What is the importance of modeling ?
Types of things used in UML: Things can be divided into several different
categories:
1. Structural things: Nouns that depicts the static behavior of a model is
termed as structural things. They display the physical and conceptual
components. They include class, object, interface, node, collaboration,
component, and a use case.
2. Behavioral things: They are the verbs that encompass the dynamic parts
of a model. It depicts the behavior of a system. They involve state machine,
activity diagram, interaction diagram, grouping things, annotation things.
Ans.
Abstract class :
[Link] abstract class is a class that contains at least one abstract method.
[Link] we want to add new methods in the future, then an abstract class is used.
23 What do you mean by modeling? Discuss several purposes served by models with suitable
examples.
1.A model is an abstraction of something for the purpose of understanding it before building it.
[Link] a model leave out non essential detail, it is easier to manipulate them.
[Link] build hardware and software systems, the developer needs to :
[Link] different views of the system.
ii Build models using precise notations.
[Link] sure that the model satisfy the requirements of the system.
[Link] details to transform the model into an implementation.
[Link] serves the following purpose :
[Link] a physical entity before building it :
[Link] a model is cheaper. Also, it provides information that is too
inaccessible to be measured from physical model.
[Link] models are usually cheaper than building a complete system
and it enable flaws to be corrected early.
For example : Scale models of airplane and cars are tested in wind tunnels to
improve their aerodynamic.
[Link] with customers :
[Link] designers build models to show their [Link] example :
Demonstration products like mock-ups that imitate some Or all of the external
behavior of a system.
[Link] :
[Link] of movies, television shows, and advertisements allow the writers
to see how their idea flows.
[Link] models unnecessary segments can be modified before the final
development begins.
[Link] of complexity :
[Link] helps in understanding the systems that are too complex to
understand directly.
[Link] reduces complexity by leaving out the non essential details
2. Multiplicity specifies the number of instances of one class that may relate to
a single instance of an associated class.
25 Importance of modeling :
Modeling help the development team better to visualize the plan of their
system and allow them to develop more rapidly by helping them build
the right thing.
26 Define link and association. Discuss the role of link and association in object modeling
with suitable example
Aggregation:
1. Aggregation is a stronger form of association. It represents the has-a or
part-of relationship.
4. Hence object aggregation helps us describe models of the real world that
are composed of other models, as well as those that are composed of still
other models.
Association:
1. Association is the semantic relationship between classes that shows how
one instance is connected or merged with others in a system.
2. The objects are combined either logically or physically. Since it connects the
object of one class to the object of another class, it is categorized as a
structural relationship.
i. implicit: Implicit constraints define that the relationship is not visible, but it
is based on a concept.
ii. ordered: It describes that the set of entities is in a particular way at one
end in an association.
iv. addonly: It specifies that any new connection can be added from an
object located at the other end in an association.
[Link] : Actors are instances that invoke the interaction in the diagram. Each actor has
a name and a role, with one actor initiating the entire use case.
[Link] : Links connect objects with actors and are depicted using a
solid line between two elements. Each link is an instance where
messages can be sent.
[Link] : Messages between objects are shown as a labeled arrow placed near a
link. These messages are communications between objects that convey information
about the activity and can include the sequence number.
Polymorphism using collaboration diagram :
[Link]. 3 uses a collaboration diagram to illustrate polymorphism in a business scenario.
[Link] diagram assumes that there are different ways of calculating an employee’s pay.
[Link]-time employees are paid a salary that depends only on his or her grade; part-time
staff are paid a salary that depends in a similar way on grade, but must also take into
account the number of hours worked; temporary staff differ in that no deductions are
made for the company pension scheme, but the salary calculation is otherwise the same
as for a full-time employee.
[Link] object-oriented system to calculate pay for these employees might include a
separate class for each type of employee, each able to perform the appropriate pay
calculation.
[Link], following the principle of polymorphism, the message signature for all
calculate pay operations is the same.
[Link] one of the outputs from this system is a print-out showing the total pay for the
current month: to assemble the total, a message is sent to each employee object, asking
it to calculate its pay.
[Link] the message signature is the same in each case, the requesting object (here
called MonthlyPayPrint) need not know that the class of each receiving object, still less
how each calculation is carried out
31
What do you mean by polymorphism ? Is this concept only
applicable to object-oriented systems ? Explain.
Polymorphim :
[Link] means having many forms.
[Link] is the ability of a message to be displayed in more
than one form.
[Link] plays an important role in allowing objects having different
internal structure to share the same external interface.
Applicability of polymorphism :
[Link] programming languages there are two types of polymorphism
ad-hoc and universal.
[Link] are two kinds of universal polymorphism: parametric and
subtyping.
[Link]-hoc polymorphism is a kind of polymorphism in which
polymorphic functions can be applied to arguments of different
types
[Link] universal (parametric) polymorphism, the polymorphic functions
are written without mention of any specific type.
[Link] ad-hoc polymorphism is applicable in both traditional and object-
ori ented prog rammi ng environm ents, wher eas univer sal
polymorphism only applies to object-oriented systems.
34 State which UML diagrams give a static view and which give a dynamic view
of a system.
There are two broad categories of diagrams and they are again divided into subcategories −
· Structural Diagrams
· Behavioral Diagrams
Structural Diagrams
The structural diagrams represent the static aspect of the system. These static aspects represent th
and are therefore stable.
These static parts are represented by classes, interfaces, objects, components, and nodes. The four st
· Class diagram
· Object diagram
· Component diagram
· Deployment diagram
Behavioral diagrams
Behavioral diagrams basically capture the dynamic aspect of a system. Dynamic aspect can be furthe
UML has the following five types of behavioral diagrams −
· Use case diagram
· Sequence diagram
· Collaboration diagram
· Statechart diagram
· Activity diagram
UML was created by the Object Management Group (OMG) and UML 1.0 specification draft was prop
Need of UML
· Identify requirements and communicate information.
· Allows focus on how system components interact.
· Allows you to see relationships among design components
· Improves communication across your team using common graphical language
Benefits of UML
· Enterprise information systems
· Banking and financial services
· Telecommunications
· Transportation
· Defence/aerospace
· Retail
· Medical electronics
· Scientific
· Distributed Web-based services
Diagrams
UML diagrams are the ultimate output of the entire discussion. All the elements, relationships are u
represents a system.
The visual effect of the UML diagram is the most important part of the entire process. All the other e
UML includes the following nine diagrams, the details of which are described in the subsequent chap
· Class diagram
· Object diagram
· Use case diagram
· Sequence diagram
· Collaboration diagram
· Activity diagram
· Statechart diagram
· Deployment diagram
· Component diagram
38 Explain behavioral Diagrams and any three types of behavioral Diagrams?
Behavioral Diagrams
Any system can have two aspects, static and dynamic. So, a model is considered as complete when bo
Behavioral diagrams basically capture the dynamic aspect of a system. Dynamic aspect can be furthe
UML has the following five types of behavioral diagrams −
· Use case diagram
· Sequence diagram
· Collaboration diagram
· Statechart diagram
· Activity diagram
Use Case Diagram
Use case diagrams are a set of use cases, actors, and their relationships. They represent the use case
A use case represents a particular functionality of a system. Hence, use case diagram is used to de
their internal/external controllers. These controllers are known as actors
Sequence Diagram
A sequence diagram is an interaction diagram. From the name, it is clear that the diagram deals wit
flowing from one object to another.
Interaction among the components of a system is very important from implementation and executio
sequence of calls in a system to perform a specific functionality.
Collaboration Diagram
Collaboration diagram is another form of interaction diagram. It represents the structural organ
Structural organization consists of objects and links.
The purpose of collaboration diagram is similar to sequence diagram. However, the specific
organization of objects and their interaction.
The structural diagrams represent the static aspect of the system. These static aspects represent th
and are therefore stable.
These static parts are represented by classes, interfaces, objects, components, and nodes. The four st
· Class diagram
· Object diagram
· Component diagram
· Deployment diagram
Class Diagram
Class diagrams are the most common diagrams used in UML. Class diagram consists of classes, int
basically represent the object-oriented view of a system, which is static in nature.
Active class is used in a class diagram to represent the concurrency of the system.
Class diagram represents the object orientation of a system. Hence, it is generally used for develop
the time of system construction.
Object Diagram
Object diagrams can be described as an instance of class diagram. Thus, these diagrams are more clo
Object diagrams are a set of objects and their relationship is just like class diagrams. They also repre
The usage of object diagrams is similar to class diagrams but they are used to build prototype of a sy
40 What is modeling? What are the advantages of creating a model?What are the
different views that are considered when building an object-oriented software
system?
Association
Association is basically a set of links that connects the elements of a UML model. It also describes ho
Generalization
Generalization can be defined as a relationship which connects a specialized element with a gen
relationship in the world of objects.
Realization
Realization can be defined as a relationship in which two elements are connected. One element de
and the other one implements them. This relationship exists in case of interfaces.
Structural model represents the framework for the system and this framework is the place wher
component diagram and deployment diagrams are part of structural modeling. They all represent t
The structural model never describes the dynamic behavior of the system. Class diagram is the mos
Behavioral Modeling
Behavioral model describes the interaction in the system. It represents the interaction among t
dynamic nature of the system. They consist of the following −
· Activity diagrams
· Interaction diagrams
· Use case diagrams
All the above show the dynamic sequence of flow in a system.
Architectural Modeling
Architectural model represents the overall framework of the system. It contains both structural and
can be defined as the blueprint of the entire system. Package diagram comes under architectural m
Enumerate the graphical notations used in structural things are most widely
used in UML.
Graphical notations used in structural things are most widely used in UML. These are considered
structural things.
· Classes
· Object
· Interface
· Collaboration
· Use case
· Active classes
· Components
· Nodes
Class Notation
UML class is represented by the following figure. The diagram is
divided into four parts.
· The top section is used to name the class.
· The second one is used to show the attributes of the
class.
· The third section is used to describe the operations
performed by the class.
· The fourth section is optional to show any additional
components.
Interface Notation
Interface is represented by a circle as shown in the following figure.
It has a name which is generally written below the circle.
Interface is used to describe the functionality without
implementation. Interface is just like a template where you define
different functions, not the implementation. When a class
implements the interface, it also implements the functionality as
per requirement.
Collaboration Notation
Collaboration is represented by a dotted eclipse as shown in the
following figure. It has a name written inside the eclipse.
For example, first, a car’s template is created. Then multiple units of car are created based on that tem
Object
An object refers to the instance of the class, which contains the instance of the members and behavio
object is an actual entity to which a user interacts, whereas class is just the blueprint for that object.
characteristic behavior.
For example, a specific car.
43 What are the four basic relationships defined in UML? Give suitable
examples for usage of each type of relationships?
Relationships in UML are used to represent a connection between structural, behavioral, or groupin
or more things can relate to each other during the execution of a system. Type of UML Relationship a
Realization.
Lets study them in detail
Association
It is a set of links that connects elements of the UML model. It also defines how many objects are taki
Dependency
In a dependency relationship, as the name suggests, two or more elements are dependent on each ot
to a particular element, then it is likely possible that all the other elements will also get affected by th
Generalization
It is also called a parent-child relationship. In generalization, one element is a specialization of anoth
mostly used to represent inheritance.
Realization
In a realization relationship of UML, one entity denotes some responsibility which is not implemente
This relationship is mostly found in the case of interfaces.
What is class diagram in UML with example?Define the purpose of class
diagram.
Class diagram is a static diagram. It represents the static view of an application. Class diag
documenting different aspects of a system but also for constructing executable code of the softw
Class diagram describes the attributes and operations of a class and also the constraints impose
in the modeling of objectoriented systems because they are the only UML diagrams, which can b
Class diagram shows a collection of classes, interfaces, associations, collaborations, and constr
The purpose of class diagram is to model the static view of an application. Class diagrams are
object-oriented languages and thus widely used at the time of construction.
UML diagrams like activity diagram, sequence diagram can only give the sequence flow of the a
is the most popular UML diagram in the coder community.
44. Discuss the significance of class diagrams in modeling a system and define
benefits of class diagram also
The main purpose of class diagrams is to build a static view of an application. It is the only diagr
mapped with object-oriented languages. It is one of the most popular UML diagrams. Following are t
The class diagram is used most widely to construct software applications. It not only represents a st
an application. A collection of class diagrams as a whole represents a system.
Some key points that are needed to keep in mind while drawing a class diagram are given below:
1. To describe a complete aspect of the system, it is suggested to give a meaningful name to the class
2. The objects and their relationships should be acknowledged in advance.
3. The attributes and methods (responsibilities) of each class must be known.
4. A minimum number of desired properties should be specified as more number of the unwanted pr
5. Notes can be used as and when required by the developer to describe the aspects of a diagram.
6. The diagrams should be redrawn and reworked as many times to make it correct before producing
45 Why modeling is important list any five advantages of
modeling?
Modeling is a central part of all activities that lead up to the deployment of good software. It is req
Importance of Modeling:
Objects
Objects participating in a collaboration come in two flavors?supplier and client. Supplier objects are the ob
therefore receive the message. Client objects call methods on supplier objects, and therefore send message
Links
Messages
Messages in collaboration diagrams are shown as arrows pointing from the Client object to the Supplier ob
operation on a supplier object.
Message icons have one or more messages associated with them. Messages are composed of message text
indicates the time-ordering of the message.
3. The syntax of a collaboration diagram is similar to the sequence diagram; just the difference is tha
4. The messages transmitted over sequencing is represented by numbering each individual message
9. There may be a chance of losing some amount of information while implementing a collaboration
The drawback of a Collaboration Diagram
1. Multiple objects residing in the system can make a complex collaboration diagram, as it becomes q
2. It is a time-consuming diagram.
3. After the program terminates, the object is destroyed.
3. As the object state changes momentarily, it becomes difficult to
keep an eye on every single that has occurred inside the object of a system.
47 Describe the notation used for the collaboration diagram.
Notations of a Collaboration Diagram
Following are the components of a component diagram that are enlisted below:
Objects: The representation of an object is done by an object symbol with its name and class unde
In the collaboration diagram, firstly, the object is created, and then its class is specified.
1. Actors: In the collaboration diagram, the actor plays the main role as it invokes the intera
In this, one actor initiates the use case.
2. Links: The link is an instance of association, which associates the objects and actors. It port
which the messages are sent. It is represented by a solid line. The link helps an object to con
the message flows are attached to links.
The sequence diagrams are better suited of The collaboration diagrams are better suited
analysis activities. number of objects.
Inheritance
This post provides the theoretical explanation of inheritance with real-life examples
· Inheritance is the mechanism by which an object acquires the some/all properties of an
· It supports the concept of hierarchical classification.
For example: Car is a four wheeler vehicle so assume that we have a class FourWheeler and a sub cl
class FourWheeler. Other classifications could be a jeep, tempo, van etc. FourWheeler defines a clas
engine power, load carrying capacity etc. Car (termed as a sub-class) acquires these properties from
are different from other classifications of FourWheeler, such as luxury, comfort, shape, size, usage e
A car can have further classification such as an open car, small car, big car etc, which will acquire th
still have some specific properties. This way the level of hierarchy can be extended to any level.
Polymorphism
This post provides the theoretical explanation of polymorphism with real-life examplesPolymorphi
data type.
· In other words it means, one method with multiple implementation, for a certain class o
decided at runtime depending upon the situation (i.e., data type of the object)
· This can be implemented by designing a generic interface, which provides generic meth
classes, which provides the implementation of these generic methods.
Lets us look at same example of a car. A car have a gear transmission system. It has four front gears
then depending upon which gear is engaged different amount power and movement is delivered to
the type of gear the action behaves differently or you can say that it shows many forms (polymorph
· Overloading in simple words means more than one method having the same method n
passed while calling the method. This called static because, which method to be invoked is decided
· Overriding means a derived class is implementing a method of its super class. The call
runtime polymorphism
Synchronous Message
A synchronous message requires a response before the interaction can continue. It's usually drawn u
object to another.
Asynchronous Message
Asynchronous messages don't need a reply for interaction to continue. Like synchronous messages, t
however, the arrowhead is usually open and there's no return message depicted.
Self-Message
A message an object sends to itself, usually shown as a U-shaped arrow pointing back to itself.
Create Message
This is a message that creates a new object. Similar to a return message, it's depicted with a dashed l
representing the object created.
Delete Message
This is a message that destroys an object. It can be shown by an arrow with an x at the end.
Found Message
A message sent from an unknown recipient, shown by an arrow from an endpoint to a lifeline.
Lost Message
A message sent to an unknown recipient. It's shown by an arrow going from a lifeline to an endpoint
Synchronous Message: A synchronous message requires a response before the interaction can cont
arrowhead pointing from one object to another. If a caller sends a synchronous message, it must wai
subroutine.
Synchronous Message
Asynchronous Message: Asynchronous messages don't need a reply for interaction to continue. Lik
connecting two lifelines; however, the arrowhead is usually open and there's no return message depi
continue processing and doesn’t have to wait for a response.
52 What are the pros and cons of sequence diagram.
Benefits of a Sequence Diagram
Sequence diagrams can become complex when too many lifelines are involved in the system.
If the order of message sequence is changed, then incorrect results are produced.
Each sequence needs to be represented using different message notation, which can be a little c
The type of message decides the type of sequence inside the diagram.
53 Discuss the role of acess specifiers in inheritance and show their visibility
when they are inherited as public, private and protected.
These 3 keywords (public, protected, and private) are known as
access specifiers in C++ inheritance.
Object: A single thing or concept, either in a model of an application domain or in a software system that c
and identity, a member of a class that defines a set of similar objects.
Class: A class is a descriptor for a collection of objects that are logically similar in terms of their behavior
Instance: A single object, usually called an instance in the context of its membership of a particular c
55 What is object-oriented design (OOD), and how does it differ from other
approaches to software design?What Is Generalization and Specialization?
Generalization: Generalization is the abstraction of common feature among elements by the creation
encapsulate common features. For example, in animal world a cat and a dog share some common fea
which encapsulates common their common feature. A cat, a dog – both are consistent with mammal
Specialization: The other face of generalization is specialization. A class is said to be specialized whe
it from its super class. For example, a cat is a mammal but it is more specialized.
Either of Q 1, 2, 4 & 5 one should be Previous Year GATE Question or company specific if applicable.