Introduction to Java
Introduction:
• Focuses on the necessity of a structured approach to handle the complexity of software
applications.
Complexity:
• Emphasizes the need to identify crucial features either by focusing on activities
(algorithms) or objects (things).
• Introduces iterative decomposition to manage complexity.
Object Terminology:
• Lists four fundamental OOP concepts: Abstraction, Encapsulation, Hierarchy, and
Polymorphism.
Abstraction:
• Describes abstraction as a method to simplify the problem domain by focusing on
essential features.
• Explains that similar objects share common structures, referred to as classes.
Encapsulation:
• Highlights the separation of an object's implementation details from its external
appearance.
• Notes the importance of hiding internal structure to allow changes without affecting
client applications.
Hierarchy:
• Describes relationships between objects through aggregation ("has a" relationship) and
shared structure ("is a kind of" relationship).
Polymorphism:
• Discusses how objects can implement behaviors based on their type within a shared
hierarchy.
Summary:
• Reinforces the importance of abstraction, encapsulation, inheritance, and polymorphism
in OOP.
1
Questions and Anwsers
Q: What is the process of breaking down a problem domain into its essential features called?
A: Iterative decomposition.
Q: What fundamental OOP concept involves reducing complexity by focusing on essential
features?
A: Abstraction.
Q: What does encapsulation focus on in an object?
A: Combining the data that describes the object's state and the algorithms that define its
behavior.
Q: What is a "class" in object-oriented programming?
A: A description of the common structure and behavior shared by similar objects.
Q: What is an "object" in OOP?
A: An instance of a class.
Q: What is the term for the boundary that distinguishes one object from another?
A: Crisp boundary.
Q: How does a well-encapsulated object benefit a developer?
A: It allows changes to the object's internal structure without affecting the software that
uses the object.
Q: What type of relationship does aggregation describe?
A: A "has a" relationship between objects.
Q: What type of relationship does shared structure and behavior describe?
A: An "is a kind of" relationship, forming a hierarchy of classes.
Q: What does polymorphism relate to in OOP?
A: The implementation of an object based on its type.
2
Q: What concept allows different objects to respond differently to the same message?
A: Polymorphism.
Q: Why is encapsulation important in OOP?
A: It hides the implementation details within a class, ensuring changes do not affect client
applications.
Q: What term is interchangeable with "object" in OOP?
A: Instance.
Q: What does abstraction ignore in the problem domain?
A: Non-essential features.
Q: What are the four fundamental concepts of OOP?
A: Abstraction, encapsulation, hierarchy, and polymorphism.
Q: What is the benefit of objects sharing a common structure?
A: It allows the definition of classes that describe the structure and behavior of similar
objects.
Q: What is the focus of abstraction in OOP?
A: On the most important aspects of the problem domain.
Q: How does encapsulation affect the integrity of an object?
A: It ensures that an object can only behave in ways that are appropriate to itself.
Q: What is an example of encapsulation in a student class?
A: Having private attributes for enrollment number, name, and GPA with public methods
to access and modify them.
Q: How does hierarchy help in organizing objects?
A: By establishing parent-child relationships and class hierarchies.
3
Q: What is the advantage of using polymorphism in OOP?
A: It allows for flexibility and the ability to define methods that behave differently based
on the object type.
Q: What happens when an object is well-encapsulated?
A: Its internal details are hidden, and changes to the object's structure do not affect
external code.
Q: What is a key feature of objects in a hierarchy with shared structure and behavior?
A: They can inherit attributes and methods from parent classes.
Q: What does a class in OOP describe?
A: The structure of the data held by an object and the behavior of the object.
Q: What does encapsulation combine within an object?
A: The data that describes the object's state and the algorithms that define its behavior.
Q: What are the cornerstones of object-oriented programming?
A: Abstraction, encapsulation, inheritance, and polymorphism.
4
Q: What is the primary goal of object-oriented programming?
• To simplify coding syntax
• To represent complexity in a practical and usable manner
• To increase execution speed
• To eliminate errors
Q: What is an example of an abstraction in a course enrollment system?
• The physical location of classrooms
• A course code
• The color of the textbooks
• The type of chairs in the classroom
Q: What does encapsulation aim to hide?
• The graphical user interface
• The internal details of an object
• The programming language used
• The hardware specifications
Q: In object-oriented programming, what term is used to describe a blueprint for objects?
• Function
• Array
• Class
• Loop
Q: What type of relationship does aggregation describe?
• "Is equal to"
• "Has the same attributes as"
• "Has a"
• "Belongs to"
Q: Which OOP concept allows an object to take on many forms?
• Encapsulation
• Abstraction
• Polymorphism
• Aggregation
Q: What is the term for a real-world entity in OOP?
• Class
• Object
5
• Attribute
• Method
Q: What is encapsulation primarily concerned with?
• Making code more readable
• Hiding internal state and behavior
• Increasing the number of lines of code
• Simplifying algorithms
Q: What is the term for a class that is a blueprint for objects?
• Class
• Function
• Method
• Module
Q: Which concept involves grouping related properties and behaviors?
• Polymorphism
• Encapsulation
• Abstraction
• Hierarchy
Q: What does polymorphism allow objects to do?
• Share the same data
• Respond differently to the same method call
• Be stored in the same variable
• Have identical appearances
Q: What is an instance of a class called?
• Object
• Function
• Attribute
• Module
Q: What type of hierarchy describes an "is a kind of" relationship?
• Linear hierarchy
• Circular hierarchy
• Class hierarchy
• Random hierarchy
Q: Which concept helps reduce complexity by ignoring non-essential features?
6
• Inheritance
• Abstraction
• Polymorphism
• Encapsulation
Q: What does encapsulation combine within an object?
• Methods and functions
• Attributes and modules
• Data and algorithms
• Classes and objects
Q: What is an example of polymorphism in a course enrollment system?
• Using the same textbook for all courses
• Different course types responding to a mode() query differently
• Having a single grading scheme for all courses
• Storing all student data in one table
Q: Which of the following is NOT a fundamental OOP concept?
• Abstraction
• Encapsulation
• Iteration
• Polymorphism
Q: What do objects that share common features form?
• An algorithm
• A function
• A class
• A module
Q: What is the purpose of abstraction?
• To increase the complexity of the problem domain
• To hide the code from the user
• To reduce the execution time of a program
• To reduce the complexity by focusing on essential features
Q: What does a well-encapsulated object allow a developer to do?
• Change the internal structure without affecting external code
• Access private data directly
• Use less memory
• Write less code
7
Q: What does hierarchy in OOP help organize?
• Relationships between objects
• Execution order of functions
• Syntax rules
• Data storage locations
Q: What is an "is a kind of" relationship in OOP?
• Shared structure and behavior
• Physical location relationship
• Data storage relationship
• Execution order relationship
Q: What concept involves creating objects that have similar features?
• Polymorphism
• Class
• Aggregation
• Encapsulation
Q: What does a class describe?
• The structure and behavior of similar objects
• The sequence of function calls
• The user interface layout
• The memory allocation
Q: What is the main benefit of using classes in OOP?
• Increased execution speed
• Reduced memory usage
• Shared structure and behavior among objects
• Simplified syntax
Q: How are objects in a well-encapsulated class described?
• By hiding internal data and logic
• By exposing all internal data
• By sharing memory locations
• By reducing the number of methods
Q: What concept in OOP focuses on internal object state and behavior?
• Abstraction
• Encapsulation
8
• Polymorphism
• Aggregation
Q: What is the benefit of abstraction in OOP?
• Reducing complexity
• Increasing code length
• Hiding errors
• Decreasing execution speed
Q: What do objects that belong to the same class share?
• Common structure and behavior
• Memory locations
• Execution speed
• User interfaces
Q: What is a key feature of polymorphism in OOP?
• Increased code length
• Different responses to the same method call
• Shared memory allocation
• Simplified algorithms