Clicker quiz 10/1/13 CSE 1102 Fall 2013.

Slides:



Advertisements
Similar presentations
More on Classes Inheritance and Polymorphism
Advertisements

Based on Java Software Development, 5th Ed. By Lewis &Loftus
So what's next? Introduction to data structures Two Perspectives: Abstract description (capabilities) Implementation(s) For structures: Stack Queue Deque.
Programming With Java ICS201 University Of Hail1 Chapter 13 Inner Classes.
Reusable Classes.  Motivation: Write less code!
Classes and SubClasses Super Parent Sub Child IS - A.
Help Session How To Get Started Design Parameters
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Fall 2007CSE 115/503 Introduction to Computer Science for Majors I1 Association relationship We’ve seen one implementation of “knows a”: public class Dog.
Syntax & terminology review While the following slides are not exactly what we did on the board (object diagrams are not shown here) they cover most of.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Reminder Check the course web site on a regular basis:
Week 4 Recap CSE 115 Spring Formal Parameter Lists Comma-separated list of formal parameters Formal parameters are listed giving the type of the.
Week 6 Recap CSE 115 Spring Review We have built a program that uses Association, Composition, Instantiation Dependency, Local Instance Dependency,
CS 106 Introduction to Computer Science I 03 / 21 / 2008 Instructor: Michael Eckmann.
Fall 2007CSE 115/503 Introduction to Computer Science for Majors I1 Announcements Attendance sheet is going around – be sure you sign it! First part of.
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Composition details Recall, composition involves 3 things: –Declaration of instance variable of.
Polymorphism CSE 115 Spring 2006 March 6, 8 & 10, 2006.
More C++ Bryce Boe 2013/07/18 CS24, Summer 2013 C.
Lecture 7 Polymorphism. Review: Constructors ●Parenthesis after constructor, not in class declaration ●The constructor makes the SamBot – do not “ new.
Question of the Day  Write valid mathematical equation using: one addition operator (‘+’) one equality operator (‘=’)  Should have equal values.
© 2006 Pearson EducationInterfaces1 of 28 INTERFACES Declaring Interfaces Implementing Interfaces Using Interfaces Polymorphically Visibility Modifiers.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
Local Variables Garbage collection. © 2006 Pearson EducationParameters2 of 10 Using Accessors and Mutators Together What if you want to get a property.
Andries van Dam  /01/15 1/38 Initial Questionnaire – The Results Are In! 56% of all students in CS15 have no prior coding experience! 81% of all.
Question of the Day  Write valid mathematical equation using: one addition operator (‘+’) one equality operator (‘=’)  Should have equal values.
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
ECE122 Feb. 22, Any question on Vehicle sample code?
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
LECTURE 9: INTERFACES & ABSTRACT CLASSES CSC 212 – Data Structures.
Java - Classes JPatterson. What is a class? public class _Alpha { public static void main(String [] args) { } You have been using classes all year – you.
Computer Science 111 Fundamentals of Computer Programming I Working with our own classes.
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
Newport Robotics Group 1 Tuesdays, 6:30 – 8:30 PM Newport High School Week 4 10/23/2014.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Encapsulation, Inheritance, Composition. Class Methods Can be either void or return Can have parameters or not Must be static Should be public Know how.
Clicker quiz 10/8/13 CSE 1102 Fall 2013 (E-30 reminder!)
CS1101 Group1 Discussion 6 Lek Hsiang Hui comp.nus.edu.sg
Quick topix 11/7/13 CSE 1102 Fall previous statement Execute rest of program Is true? yes no This flowchart illustrates the logic of a _________.
Inheritance and Polymorphism
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
Java Inheritance 1/13/2015. Learning Objectives Understand how inheritance promotes software reusability Understand notions of superclasses and subclasses.
Clicker quiz 9/3/13 CSE 1102 Fall Look out behind you! The picture associated with one of the instructors on Piazza includes an animal. That animal.
Clicker quiz 9/17/13 CSE 1102 Fall // In Blob: public void mousePressed(MouseEvent e){ this.setFillColor(java.awt.Color.blue); } // in WinkingBlob.
Clicker questions 10/3/13 CSE 1102 Fall public class { … private _ ; public ) { … _ = ; … } … } In the above code, what is the purpose of the parameter.
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);
C++ Features Function Overloading Default Functions arguments Thinking about objects – relationship to classes Types of member functions Constructor and.
Today Encapsulation. Build a fully encapsulated Halloween class, going from Halloween1 to Halloween6 (eventually!): –The final version will have overloaded.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Clicker questions 10/3/13 CSE 1102 Fall 2013.
9.1 Class (static) Variables and Methods
Haidong Xue Summer 2011, at GSU
Intro To Classes Review
Chapter 3: Using Methods, Classes, and Objects
CMPE212 – Stuff… Exercises 4, 5 and 6 are all fair game now.
CS 302 Week 11 Jim Williams, PhD.
Java Inheritance.
Clicker quiz 10/15/13 CSE 1102 Fall 2013.
Implementing Non-Static Features
Singleton design pattern
The Object-Oriented Thought Process Chapter 04
Defining Classes and Methods
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
Fundaments of Game Design
Agenda Inheritance Polymorphism Type compatibility Homework.
Java Inheritance.
Day 11 The Last Week!.
Presentation transcript:

Clicker quiz 10/1/13 CSE 1102 Fall 2013

The above code illustrates what recipe? public class Sun extends Ellipse { public Sun(Color c) { super(c); … } public Sun() { this(Color.yellow); The above code illustrates what recipe? Default value [correct] Accessors and mutators Parts that know about their containers Sharing the interface Invisible sun

The above code illustrates what recipe? public class Sun extends Ellipse { private Color _myColor; public Sun(Color c) { super(c); _myColor = c;; } public Color getColor(){ return _myColor; public void setColor(Color col){ _myColor = col; The above code illustrates what recipe? Default value Accessors and mutators [correct] Parts that know about their containers Sharing the interface Here comes the sun

public class Forest { Bird _tweety; … } Suppose _tweety is declared to be a Bird (as above). Given this diagram the actual type of _tweety can be Bird Bird, Crow, or Duck [correct] Bird or Animal Bird, Crow, Duck, or Animal

Using only the information in this diagram, if we want to be able to make the assignment sporty = new Car(3); sporty would have been declared a Car Car or Vehicle Car or PeopleMover Car, Vehicle, or PeopleMover [correct]

Clicker questions 10/1/13 CSE 1102 Fall 2013

public class <ContainerClass> { … private <PartClass> _<part>; public <ContainerClass>(…) { _part = new <PartClass>(this); } public class Hat { … private HatPart _myHatPart; public Hat() { _myHatPart = new HatPart(this); } In the above code, to what does this in line 7 refer? A constructor for <ContainerClass> A constructor for <PartClass> _part An instance of <ContainerClass> [correct] An instance of <PartClass> A constructor for Hat A constructor for HatPart _myHatPart An instance of Hat [correct] An instance of HatPart

Given the above diagram, which line of code is not legal? Vehicle oily = new OilTanker(200); Car frank = new Car(); PeopleMover pm = new Car(3); OilTanker oily = new Truck(42); [correct] More than two of these are not legal

… Vehicle robyn; robyn = new Car(200); In the code above, after robyn gets instantiated, which methods can be invoked on robyn? (i.e. robyn.???) holdPeople, tootHorn, carryCargo, and move holdPeople, tootHorn, and move holdPeople and move carryCargo and move [correct] carryCargo only

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