CS 46B - Lecture 1

Cover page image

Cay S. Horstmann

CS 46B

Active Learning

Changing the brain

What You Need to Succeed

Prerequisites
  • CS1 in Java
  • Completion or concurrent enrollment in discrete math
  • Time
  • Study habits
  • Your Responsibilities

    Homework

    Lab

    ???

    The Textbook

    Adding

    Things To Do Today

    Inheritance Hierarchies


    hierarchy of vehicles

    Inheritance Hierarchies

    inheritance diagram

    Inheritance Hierarchies

    Lecture 1 Clicker Question 1

    Consider the method doSomething(Car c). Name the class whose objects cannot be passed to this method.
    vehicle hierarcy

    1. Car
    2. Sedan
    3. SUV
    4. Vehicle

    Inheritance Hierarchies

    Example: Computer-graded quiz

    question hierarchy

    Implementing Subclasses

    Implementing Subclasses

    Implementing Subclasses

    A ChoiceQuestion object differs from a Question object in three ways:

    Implementing Subclasses

    UML of the ChoiceQuestion

    Implementing Subclasses

    Implementing Subclasses

    Lecture 1 Clicker Question 2

    Which of the following statements is true?

    1. Question is a subclass of ChoiceQuestion
    2. The ChoiceQuestion class overrides the setText method of Question
    3. The ChoiceQuestion class inherits the checkAnswer method of Question
    4. The ChoiceQuestion method inherits the display method of Question

    Lecture 1 Clicker Question 3

    Suppose q is an object of the class Question and cq an object of the class ChoiceQuestion. Which of the following calls is not legal?

    1. q.setAnswer(response)
    2. cq.setAnswer(response)
    3. q.addChoice(choice, true)
    4. cq.addChoice(choice, true)

    Before Next Class