Skip to content

Github-Amity/Interfaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Interfaces

What to know

Before you begin this project, you need to be familiar with interfaces in Java.

If you are not familiar with it already, watch this tutorial.

It is highly recommended to type and run the code along with the video on any IDE or using an online compiler such as online-java.com.

The Project - Calc

Write a program with one interface and a normal class that implements the interface. Implement the method in the interface and then call the method. Also print the attribute defined in the interface. This project will let you experiment with interfaces.

Instructions

  • Getting the code:

    • If you're using an online compiler: Copy the code from the project file Calc.java and paste it in an online java compiler. Change the class name and its references to "Main" to match the file name of the online compiler (or you can create a new file in the online compiler and name it the same as the file name given here). Watch this tutorial for full comprehension.

    • If you're using a code editor IDE: Download the code (ZIP file). Watch this to learn how to do that.

    • If you have git installed: Clone the repository.

  • Code format

    • There are three blocks of code you need to add. Each block comes with a number (example: // 1️⃣ FIRST) that indicates the order in which you must do the project. Complete the first block before moving on to the second. The instructions for the code you need to write are given with 🔴 emoji and the areas are marked with ⬇️⬆️ emojis. Do NOT write anything outside these areas.
    • Once you are done, run the code in your editor and make sure that your method is correct and your the format of your output matches the one given below.
  • Output:

    image
    • Your program should print two numbers in two different lines. The first number is the result of your method and the second number is the value of pi.
      Note: The first number depends on the operation and numbers you choose.
  • Project Submission:

    • If you're using an online compiler: Simply create a new file, add your filename including your name (eg: SalmaCalc.java) and open a pull request. Watch this to learn how to do that.
    • If you're using a code editor IDE: Before submitting, change the name of the file to include your name. Watch this to learn how to do that.
      For example:
      If your name is Salma, change the name of the file to SalmaCalc.java
    • Similarly, change the name of your class (and all its references) to include your name (otherwise, the code will not run in your IDE).
    • Then create a fork of this repository, submit your file and open a pull request. Watch this to learn how to do that.

Notes on Interfaces:

  • Like abstract classes, interfaces cannot be used to create objects.
  • Interface methods do not have a body - the body is provided by the "implement" class.
  • On implementation of an interface, you must override all of its methods.
  • Interface methods are by default abstract and public.
  • Interface attributes are by default public, static and final.
  • A class can inherit multiple interfaces.

Congratulations on completing the project!

About

A project on Java interfaces

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages