QUESTIONS APPLICABLE TO SOFTWARE ENGINEERING
INTERVIEW QUESTIONS AND CORRECT DETAILED
ANSWERS WITH RATIONALES|GUARANTEED PASS
Object - ANSWER: An instance of a class
Class - ANSWER: Blueprint/prototype from which objects are created
Inheritance - ANSWER: subclasses can inherit states/behaviors of superclasses
interface - ANSWER: contract between class and outside world; when a class
implements an interface, it promises to provide the behavior published by that
interface
package - ANSWER: a namespace for organizing classes & interfaces in a logical
manner; makes large software projects easier to manage
Encapsulation - ANSWER: Hiding the internal state of an object and requiring all
interaction to be performed through an object's methods (accessors and mutators).
Example: In a Bicycle class, method changeGear() could be implemented so as to
only accept values between 1 and 6
Benefits of Objects - ANSWER: Modularity
Information-Hiding
Code re-use
Pluggability and debugging ease
Modularity - ANSWER: source code for an object can be written/maintained
independently of source code for other objects. objects can be easily passed around
the system once they've been created.
Information-Hiding - ANSWER: By interacting only with object's methods, details of
internal implementation stay secret from outside world.
Code re-use - ANSWER: Complex objects only need to be coded once; you can use
classes that have already been created by others.
Pluggability/Debugging Ease - ANSWER: If an object is causing problems, you can
easily remove it and put something else in its place.
Example: replace a bolt that is broken, not the whole machine.
,How to use the changeGear() method on a Bicycle bike1? - ANSWER:
bike1.changeGear();
How many superclasses can a subclass have? - ANSWER: ONLY ONE
How many subclasses can inherit from the same superclass? - ANSWER: Infinitely
many
What is the main benefit of using inheritance? - ANSWER: The subclass contains all
of the methods/fields of the superclass, but the subclass' code focuses on the unique
aspects, making code simpler and easier to read.
Why must the superclass' code be carefully documented? - ANSWER: Because that
code is not physically in the subclass.
Interface - ANSWER: the methods that a class is required to contain; empty methods
that are related
Should the methods in an interface be public or private? - ANSWER: MUST be public
Packages - ANSWER: organizes a set of related classes/interfaces; like a folder on
your computer
class library - ANSWER: a set of packages
API - ANSWER: Application Programming Language: Java's library of classes that you
can use in your own applications.
What do the Java API's packages represent? Give examples. - ANSWER: tasks for
general purpose programming: String, File, Socket, some for developing GUIs.
What is a benefit of using packages? - ANSWER: It allows developers to focus on the
design of an application and NOT the technical stuff that makes it work.
Real-world objects contain BLANK and BLANK. - ANSWER: State, behavior
A software object's state is stored in BLANK - ANSWER: fields
A software object's behavior is exposed through BLANK - ANSWER: methods
(functions)
Hiding internal data from the outside world, and accessing it only through publicly
exposed methods is known as data BLANK - ANSWER: Encapsulation
A blueprint for a software object is called a BLANK - ANSWER: class
,Common behavior can be defined in a BLANK and inherited into a BLANK using the
BLANK keyword - ANSWER: superclass, subclass, extends
A collection of methods with no implementation is called an BLANK - ANSWER:
interface
A namespace that organizes classes and interfaces by functionality is called a BLANK
- ANSWER: package
The term API stands for BLANK - ANSWER: Application Programming Interface
Major Principles of Object-Oriented Programming - ANSWER: Encapsulation
Abstraction
Inheritance
Polymorphism
Accessor - ANSWER: method used to ask an object about itself
Should an accessor be public or private? - ANSWER: must be public
An accessor is any public method that gives information about the BLANK of an
object. - ANSWER: state
Mutator - ANSWER: public methods used to modify the state of an object while
hiding the implementation of the method
Benefits of Encapsulation - ANSWER: 1. You can make changes to a class without
breaking other code using that class.
2. You can handle situations where the class is being used improperly in such a way
that the code doesn't fail.
Abstraction - ANSWER: development of classes/objects/types in terms of interfaces
and functionality, instead of implementation details;
development of a software object to represent a real-world object.
Main benefit of abstraction - ANSWER: manages complexity
How does abstraction manage complexity? - ANSWER: Decomposes complex
systems into smaller components;
You know what behavior to expect from the object even before it is fully
implemented, so it won't have a negative impact on later coding if it isn't completely
finished.
, Benefit of inheritance - ANSWER: Don't have to re-use the code for characteristics
shared by all of a type/group of objects
Superclass - ANSWER: only contain info common to all of its subclasses
Types of Polymorphism - ANSWER: 1. Overriding
2. Overloading
Overriding - ANSWER: Run-time polymorphism is determined at run-time based on
the type of the object
Overloading - ANSWER: Compile-time polymorphism: the compiler determines which
method will be executed based on which parameters were supplied. Multiple
methods with different signatures (different parameters).
Can you override a method in a subclass that has a different signature in its
superclass? - ANSWER: NO, in order to override the method must have the same
signature in both the subclass and the base (super) class.
Primary goal of software architecture - ANSWER: define the non-functional
requirements of a system and define the environment; consists of the design
followed by a definition of how to deliver the functional behavior within the
architectural rules
Benefits of software architecture - ANSWER: Controls Complexity
Enforces best practices
Consistency/uniformity
Increases predictability
Enables re-use
Behavior - ANSWER: set of activities performed by an object
What does a class consist of? - ANSWER: Name, attributes and operations (state and
behavior)
5 Principles of designing a Class - ANSWER: 1. SRP (Single Responsibility Principle)
2. OCP (Open Closed Principle)
3. LSP (Liskov Substitution Principle)
4. DIP (Dependency Inversion Principle)
5. ISP (Interface Segregation Principle)