JOOPs Through Java
Challenge roadmap
0/30 Days Completed 0 Learning Days

Day 30 of 30 · Final Stretch

Final challenge + assessment

Final challenge + assessment

1 Learn

This is the finish line! First, complete the final coding challenge below. Then take the 10-question assessment.

You need at least 7 out of 10 correct to complete Day 30. You can retry the assessment as many times as you like.

2 The Final Challenge

Java
// FINAL CHALLENGE — build this yourself, then compare.
interface Reportable { void report(); }

abstract class Member implements Reportable {
    private final String name;
    Member(String name) { this.name = name; }
    String getName() { return name; }
    abstract double fee();
    public void report() {
        System.out.println(getName() + " pays " + fee());
    }
}

class StudentMember extends Member {
    StudentMember(String n) { super(n); }
    double fee() { return 100; }
}

class StaffMember extends Member {
    private final int years;
    StaffMember(String n, int years) { super(n); this.years = years; }
    double fee() { return years > 5 ? 150 : 250; }
}

public class Club {
    public static void main(String[] args) {
        Member[] all = { new StudentMember("Ananya"), new StaffMember("Ravi", 8) };
        double total = 0;
        for (Member m : all) { m.report(); total += m.fee(); }
        System.out.println("Total: " + total);
    }
}
  • Task: write a Club program with an interface, an abstract class, two subclasses, private fields, constructors using super, a loop over an array, and a decision.
  • Try it first without looking; then use this version to check your thinking.

Output

Ananya pays 100.0
Ravi pays 150.0
Total: 250.0

3 Practice

  • Add a GuestMember that pays 300.
  • Print how many members pay more than 120.

Try it in your own Java setup or write it in the Practice Notebook.

4 Final Assessment

Score at least 7/10 to finish the challenge.

  1. 1. Which method is the standard entry point of a Java application?

  2. 2. What prints? int x = 5; x += 3; System.out.println(x);

  3. 3. Which loop always runs at least once?

  4. 4. "Java".charAt(2) is?

  5. 5. A blueprint for objects is a...

  6. 6. Which keyword calls the parent constructor?

  7. 7. Making fields private and using getters/setters is...

  8. 8. Same method name, different parameters, same class is...

  9. 9. Which cannot be instantiated with new?

  10. 10. A class that uses an interface writes...

Step 5

Pass the final assessment above to unlock this.