This exercise involves creating and working with classes and interfaces in Java. The goal is to create the following:
-
A class named "Phone" with attributes
brand
andmodel
, and a methodcall()
. This method should receive aString
with a phone number and display a message in the console indicating that the number is being called. -
An interface named "Camera" with a method
photograph()
and another interface named "Clock" with a methodalarm()
. -
A class named "Smartphone" that inherits from "Phone" and implements both "Camera" and "Clock".
- The
photograph()
method should display in the console: “Taking a photo”. - The
alarm()
method should display in the console: “Alarm is ringing”.
Finally, create a Smartphone
object in the main()
method of the application and invoke these methods.
- Java - Programming language used for the implementation.
- Java Development Kit (JDK) - Required for compilation and execution.
- Integrated Development Environment (IDE) - Such as IntelliJ IDEA, Eclipse, or VS Code, for coding and debugging.
- JDK Version: Minimum 11 or newer.
- Dependencies: None.
- Operating System: Windows, macOS, or Linux.
- Install the JDK if not already installed.
- Clone or download the repository to your local machine.
- Open the project folder in your preferred IDE.
- Compile the Java files using the IDE or the terminal with the command:
javac Phone.java Camera.java Clock.java Smartphone.java Main.java