Clicker questions 10/3/13 CSE 1102 Fall 2013. public class { … private _ ; public ) { … _ = ; … } … } In the above code, what is the purpose of the parameter.

Slides:



Advertisements
Similar presentations
So what's next? Introduction to data structures Two Perspectives: Abstract description (capabilities) Implementation(s) For structures: Stack Queue Deque.
Advertisements

Reusable Classes.  Motivation: Write less code!
Copyright © 2012 Pearson Education, Inc. Chapter 4 Inheritance and Polymorphism.
Week 8 Recap CSE 115 Spring Composite Revisited Once we create a composite object, it can itself refer to composites. Once we create a composite.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
Abstract Classes and Interfaces The objectives of this chapter are: To explore the concept of abstract classes To understand interfaces To understand the.
Inheritance Inheritance Reserved word protected Reserved word super
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
CS 106 Introduction to Computer Science I 11 / 20 / 2006 Instructor: Michael Eckmann.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
UML Class Diagram: class Rectangle
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
Abstract Classes b b An abstract class is a placeholder in a class hierarchy that represents a generic concept b b An abstract class cannot be instantiated.
Inheritance. Types of Inheritance Implementation inheritance means that a type derives from a base type, taking all the base type’s member fields and.
Lecture 7 Polymorphism. Review: Constructors ●Parenthesis after constructor, not in class declaration ●The constructor makes the SamBot – do not “ new.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
Lecture 9 Polymorphism Richard Gesick.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
CSE 501N Fall ‘09 14: Inheritance 20 October 2009 Nick Leidenfrost.
COP 2800 Lake Sumter State College Mark Wilson, Instructor.
ECE122 Feb. 22, Any question on Vehicle sample code?
A girl and a boy are each holding a ball. The girl throws her ball, and the boy drops his ball. Which statement describes the motion energy (kinetic energy)
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Question of the Day  Thieves guild states it will sell to members: lock picking kits  $0.67 each 40’ rope  $2.12 each Wire cutters  $4.49 each How.
CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance.
Clicker questions 11/14/13 CSE 1102 Fall A. Composite B. Holder C. Proxy D. Factory E. Impossible to tell from diagram In this example, we want.
Clicker questions 10/24/13 CSE 1102 Fall θ (x,y) (0,0) What is the relationship between θ and (x,y) ? A.y = mx + b B.θ = x 2 + y 2 C.tan(θ) = x/y;
MIT AITI 2004 – Lecture 13 Abstract Classes and Interfaces.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Clicker quick questions 10/17/13 CSE 1102 Fall 2013.
Coming up: Inheritance
Clicker quiz 10/8/13 CSE 1102 Fall 2013 (E-30 reminder!)
Subclassing, pt. 2 Method overriding, virtual methods, abstract classes/methods COMP 401, Fall 2014 Lecture 9 9/16/2014.
Inheritance and Polymorphism
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
This In Java, the keyword this allows an object to refer to itself. Or, in other words, this refers to the current object – the object whose method or.
Clicker quiz 9/17/13 CSE 1102 Fall // In Blob: public void mousePressed(MouseEvent e){ this.setFillColor(java.awt.Color.blue); } // in WinkingBlob.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Clicker quiz 10/1/13 CSE 1102 Fall public class Sun extends Ellipse { 2. public Sun(Color c) { 3. super(c); 4. … 5. } 6. public Sun() { 7. this(Color.yellow);
When you write to a file, what happens to the content that’s already there? A.The new content replaces the original content. B.The new content goes at.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Inheritance and Polymorphism
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Inheritance Notes: Using Object Oriented Design
Inheritance ITI1121 Nour El Kadri.
Clicker questions 10/3/13 CSE 1102 Fall 2013.
Review What is an object? What is a class?
Interface, Subclass, and Abstract Class Review
Inheritance and Polymorphism
Agenda Warmup AP Exam Review: Litvin A2
Clicker quiz 10/1/13 CSE 1102 Fall 2013.
Class Inheritance (Cont.)
Lecture 22 Inheritance Richard Gesick.
Week 6 Object-Oriented Programming (2): Polymorphism
Fundaments of Game Design
Agenda Inheritance Polymorphism Type compatibility Homework.
Static Binding Static binding chooses the function in the class of the base class pointer, ignoring any versions in the class of the object actually.
Computer Science II for Majors
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

Clicker questions 10/3/13 CSE 1102 Fall 2013

public class { … private _ ; public ) { … _ = ; … } … } In the above code, what is the purpose of the parameter ? A.It sets a default value for _ object B.It is used to initialize _ when we instantiate a C.It is used to instantiate _ when we instantiate a D.It lets us change the value of _container in an existing instance E.All of the above public class HatPart { … private Hat _myHat; public HatPart(Hat aHat){ … _myHat= aHat; … } … } In the above code, what is the purpose of the parameter aHat? A.It sets a default value for _myHat object B.It is used to initialize _myHat when we instantiate a HatPart [correct] C.It is used to instantiate _myHat when we instantiate a HatPart D.It lets us change the value of _myHat in an existing HatPart instance E.All of the above

Notice from the diagram that Rectangle is not linked to Draggable. What does this imply? A.HatPart must define all of the Draggable methods independent of Rectangle B.Someone forgot to put the link in the diagram C.Rectangle.java does not include the phrase implements Draggable D.Either A or B above E.Either B or C above [correct]

In the code above, which move method gets executed? A.The move method defined in OilTanker B.The move method defined in Truck C.The move method defined in Vehicle D.All of the above E.The code does not work [correct] … OilTanker oily = new Truck(200); … oily.move();

Given the above class diagram, and the code on the right, what happens when the last line (_tree.prepareForWinter();) is executed? A.The prepareForWinter method defined in Oak is used [correct] B.The prepareForWinter method defined in Pine is used C.The prepareForWinter method defined in Tree is used D.The last line does not get executed since _tree = new Oak(); causes an error E.None of the above private Tree _tree;... _tree = new Oak();... _tree.prepareForWinter();

Suppose Russell is a Crow, and lives in an Oak. What can replace ??? above? A.prepareForWinter(); B.absorbWater(); C.dropLeaves(); D.Any public method from Tree or anything above it in the inheritance hierarchy [correct] E.Any public method from Oak or anything above it in the inheritance hierarchy public class Crow extends Bird { private Tree _myTree;... public void battenDown(){... _myTree.??? }

Suppose an Oak prepares for winter like a Tree, but it drops its leaves first. What code should replace ??? above? A.Tree.prepareForWinter(); B.super.this(); C.super.prepareForWinter(); [correct] D.this.absorbWater(); E.super(this); public class Oak extends Tree {... public void prepareForWinter(){ this.dropLeaves(); ??? }

Example: Death Race 2000 Your task: to produce a new video game. It works by instantiating a DeathRace between 2 cars using the constructor, then calling its runTheRace method, which returns the winner. public class DeathRace { Car _car1, _car2; public DeathRace(Car c1,Car c2){ _car1 = c1; _car2 = c2;... } public Car runTheRace(){ Car winner;... _car1.move(); _car2.move();... return winner; }

Car

The formal parameter type for add in Holder is Holdable. What does that require in any non-abstract class that implements Holder? A.It has a method add whose formal parameter type implements Holdable B.The definition of its add method has signature add(Holdable) [correct] C.It will not compile, since Holdable is an interface, not a class. D.It has an abstract add method E.None of the above public interface Holder { void add(Holdable h); Holdable release(); } public interface Holdable { Weight getWeight); Dimension getDimensions(); }