Skip to main content

Lab 6.5 (Oakland): Java

We know that students entered this class with a range of Java experience and that there are aspects of Java that many people find confusing, even with prior experience. The purpose of this lab is to help you level up your Java ability.

Lo-fi pixel art showing a cozy veterinary classroom where cats, dogs, and a husky in a Northeastern hoodie demonstrate Java concepts. On one side, five cats share a couch and cat tree (labeled 'static') while each has a unique collar and match food bowl (labeled 'instance').In the center, the husky plays music on a stage surrounded by a piano, drums, and guitar. There are ground hogs wearing superhero outfits. A whiteboard shows a class hierarchy tree: Animal at top, Cat and Dog below, with arrows. A happy student holds a leash attached to a dog on the ground. A confident young woman with a coffee cup with a Java icon sits at a computer desk. There are a few comic books and a small copy of Effective Java on the floor. Through the window, sunny afternoon light. Sticky notes on the wall: 'static = shared', 'override ≠ overload', 'No NPEs', 'growth mindset'. Warm yellows and cozy blues. Title: 'Lab 6.5: Java'.

Learning Objectives

By the end of this lab, you will be able to explain:

  • The difference between static and instance methods and how to call them
  • The difference between static and instance variables and how to reference them
  • What overloading is and how overloaded methods are resolved
  • What overriding is and how overridden methods are resolved
  • What a default no-arg constructor is
  • How subclasses call constructors in their superclass
  • How subclasses can call methods in their superclass
  • What happens if reference instance variables are not initialized
  • Which operations can be performed on null
  • When NullPointerException occurs

Lab Structure (100 minutes)

  1. Lecture (25 minutes)
  2. Group work on questions (10-60 minutes)
    • Students should open questions only when instructed.
    • Students are required to work collaboratively on the questions.
    • Students must check out with lab leaders, who will view their answers and ask for explanations.
  3. Exit survey (5 minutes)

Students may leave when they have completed the exit survey and been excused by a lab leader.

Resources

These resources were shared after lab for students who were unable to attend.