Page 392 - Computer_Science_F5
P. 392
entities and encapsulation to protect constructors to initialize object
book information. states and demonstrate method
6. Implement a Java program to overriding in subclasses.
demonstrate polymorphism by 11. Develop a Java program to manage Chapter Five: Object oriented programming with Java
FOR ONLINE READING ONLY
creating a base class “Shape” employee information with classes
with methods like draw() and like Employee, Manager, and
calculateArea(). Then, create Intern. Use inheritance to represent
subclasses like Circle, Rectangle, different employee roles and
and Triangle to override encapsulation to protect sensitive
employee data.
these methods with specific 12. Write a Java application to model
implementations. a simple game with classes like
7. Develop a Java application to Player, Enemy, and Weapon.
simulate a shopping cart system with Demonstrate polymorphism by
classes like Product, ShoppingCart, allowing different types of players
and enemies to interact with each
and Customer. Use encapsulation other.
to protect the cart’s contents and 13. Implement a Java program to handle
inheritance to represent different exceptions in file I/O operations.
types of customers. Use try-catch blocks to handle
8. Write a Java program to potential errors like file not found
or permission denied.
perform basic arithmetic 14. Create a Java program to
operations (addition, subtraction, demonstrate operator precedence
multiplication, division) using by performing complex arithmetic
methods and operators. Use expressions involving addition,
variables to store operands and subtraction, multiplication, and
division.
results. 15. Develop a Java application to
9. Implement a Java program to define implement a basic calculator with
and use constants for mathematical methods for arithmetic operations
constants like Pi (π) and Euler’s like addition, subtraction,
multiplication, and division. Use
number (e). Use these constants method overloading to handle
in calculations throughout the different parameter types and
program. numbers of operands.
10. Create a Java application to model 16. Explore the following plain text
of OOP codes, then answer the
a school system with classes like questions that follows:
Student, Teacher, and Course. Use
383
Student’s Book Form Five
Computer Science Form 5.indd 383 23/07/2024 12:34

