Clicker questions 10/24/13 CSE 1102 Fall 2013. θ (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;

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

Abstract Class and Interface
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
Java Interface, Abstract Class, and Event-Driven Animations
Applets & Applications CSC 171 FALL 2001 LECTURE 15.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
Animation To animate our programs, that is, to have real time interactions where objects move on the screen, we want to call repaint( ) every few milliseconds.
OOP Languages: Java vs C++
Inheritance using Java
Programming Languages and Paradigms Object-Oriented Programming.
Intro to OOP with Java, C. Thomas Wu
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 9 Clicker Questions September 29, 2009.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Screen Saver Application.
Quiz 1 What is this? (explain the use of the reserved word “this” in a class method). Answer each question briefly. – What is a Constructor? –Under what.
1 Block1 – unit 2 (The Case study in Budd 5-6).  create a small application that uses the Abstract Windowing Toolkit (AWT)  Swing packages to simulate.
Parameters… Classes Cont Mrs. C. Furman October 13, 2008.
Concurrent Programming and Threads Threads Blocking a User Interface.
Java Classes, Objects, and Events: A Preview JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria.
C# G 1 CSC 298 Object Oriented Programming Part 2.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 21.1 Test-Driving the Painter Application.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
BallWorld.java A structured walkthrough. Key Features: 2 classes are created Execution is done through the procedure called “main” which are decleared.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
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.
Chapter 5 Introduction to Defining Classes
Java Class Structure. Class Structure package declaration import statements class declaration class (static) variable declarations* instance variable.
Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor.
© 2006 Pearson EducationDesign Patterns1 of 20 A Final Example: A Traffic Light Let’s model a traffic light! – here’s the spec: Have a column of two circles.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Clicker quick questions 10/17/13 CSE 1102 Fall 2013.
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Interfaces and Inner Classes
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 27.1 Test-Driving the Drawing Shapes Application.
Clicker quiz 10/8/13 CSE 1102 Fall 2013 (E-30 reminder!)
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
Peyman Dodangeh Sharif University of Technology Fall 2014.
When is a class not a class? When it is either abstract or an Interface.
Georgia Institute of Technology More on Creating Classes part 3 Barb Ericson Georgia Institute of Technology Nov 2005.
Graphical User Interface (GUI) Two-Dimensional Graphical Shapes.
Overview of C++ Polymorphism
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 _________.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Inheritance and Polymorphism CSIS 3701: Advanced Object Oriented Programming.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Georgia Institute of Technology Comic Strip Analysis and Design Inheritance, Abstract Classes, and Polymorphism part 2 Barb Ericson Georgia Institute of.
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 _________.
Clicker quiz 11/5/13 CSE 1102 Fall A. a FlowLayout B. a BorderLayout C. a GridGrouping D. a JSplitPane E. a GridLayout Suppose we want to to lay.
Clicker questions 10/3/13 CSE 1102 Fall public class { … private _ ; public ) { … _ = ; … } … } In the above code, what is the purpose of the parameter.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
Clicker quiz 10/29/13 CSE 1102 Fall __________ is visible to code in the inner class (at ????, say): A.All protected methods and protected instance.
Last Revision. Question1 Novice Java programmers often write code similar to, class C { public int x;... }... C[] a = new C[10]; for(int i = 0; i < a.length;
1 DemoBasic_v3, DemoBasic_v4 JButton JLabel. 2 Registering an ActionListener Register by invoking the following from within constructor DemoBasicFrame.
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);
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Java Visual Applications CSIS 3701: Advanced Object Oriented Programming.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Clicker quiz 10/22/13 CSE 1102 Fall 2013.
7.1 What Is An Object Object-oriented program - Description or simulation of application Object-oriented programming is done by adopting or extending an.
GUI AND GRAPHICS.
Applets & Applications
CS240: Advanced Programming Concepts
CSC 113 Tutorial QUIZ I.
PC02 Consolidation %WITTY_QUOTE%. PC02 Consolidation %WITTY_QUOTE%
Chapter 9 Carrano Chapter 10 Small Java
CIS 199 Final Review.
Agenda Inheritance Polymorphism Type compatibility Homework.
Presentation transcript:

Clicker questions 10/24/13 CSE 1102 Fall 2013

θ (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; D.tan(θ) = y/x; [CORRECT] E.None of the above

What is the effect of line 2? Between lines 2 and 6, _____________ A._body and _tail are rotated about their center points and filled B.anything filled with aBrush will be rotated around its center point C.anything filled with aBrush will be rotated around the Fish’s center point [CORRECT] D.All of the above are true Consider the following code fragment (line numbers added) from Fish; assume java.awt.* included: 1.public void fill(Graphics2D aBrush) { 2. aBrush.rotate(_rotation, this.getCenterX(), this.getCenterY()); 3. _body.fill(aBrush); 4. _tail.fill(aBrush); aBrush.rotate(-_rotation, this.getCenterX(), this.getCenterY()); 7.}

Suppose we leave off line 5. What will be the effect? A.No effect, the animation runs the same B.The Fish will be rotated further on each tick of the timer C.It depends on the number of Fish [CORRECT] D.None of the above are true Consider the following code fragment (line numbers added) from Fish; assume java.awt.* included: 1.public void fill(Graphics2D aBrush) { 2. aBrush.rotate(_rotation, this.getCenterX(), this.getCenterY()); 3. _body.fill(aBrush); 4. _tail.fill(aBrush); 5. aBrush.rotate(-_rotation, this.getCenterX(), this.getCenterY()); 6.}

What do I need to do to get this to work ie to move the Fish on the screen? A.Make sure _myPanel is the FishPanel the Fish is in B.Register the Fish as an ActionListener of the Timer C.Both A and B. [CORRECT] D.There will be a compiler error, so it won’t work Suppose I rewrite Fish, declaring that it implements ActionListener, and includes the following code: 1.public class Fish implements Mover, ActionListener // some other Fish code 3. public void actionPerformed(ActionEvent e){ 4.this.move(); 5. _myPanel.repaint(); 6.} 7.}

__________ is visible to code in the inner class (at ????, say): A.All protected methods and protected instance variables of the outer class B.All public methods and public instance variables of the outer class C.All methods and all public instance variables of the outer class D.All methods and instance variables of the outer class. [CORRECT] E.None of the above is true Suppose I define an inner class, as was done in MoveTimer. The code in the inner class can access: 1.public class Outer extends SomeClass implements SomeInterface{ private class Inner extends AnotherClass { 4. ???? 5. } 6.}

This code illustrates which point about inner classes A.Inner classes have no constructors B.Instance variables of the outer class are visible to instances of the inner class [CORRECT] C.super can be called with null as a parameter D.An inner class is the subclass of its outer class. E.None of the above is true Consider MoveTimer: 1.public class MoveTimer extends javax.swing.Timer{ 2. private Mover _mover; 3. public MoveTimer(int anInterval, Mover aMover){ 4. super(anInterval, null); 5. _mover = aMover; 6. this.addActionListener(new MoveListener()); 7. } 8. private class MoveListener implements ActionListener { 9. public void actionPerformed(ActionEvent e) { 10. _mover.move(); 11. } 12. } 13.}

Random behavior : import java.lang.Math ; … if(Math.random() >.5) { do something } else { do something else } Another cool Math thing

About repaint Both Component and JComponent have repaint methods. Component has –public void repaint() –public void repaint(long millisecondsDelay) –public void repaint(int x, int y, int width, int height) –public void repaint(long millisecondsDelay, int x, int y, int width, int height)

More about repaint JComponent has –public void repaint(Rectangle r) –public void repaint(long timeWithin, int x, int y, int width, int height)

This code invokes which repaint method? A.The one in JComponent, because it extends JPanel. B.The one in JComponent, because the keyword “this” is used. C.The one in Component, because that is the highest in the inheritance hierarchy. D.The one in Component, because there are no arguments. E.Both, because the one in JComponent invokes the one in Component. About repaint: 1.public class FishPanel extends javax.swing.JPanel{ public FishPanel(){ 4. … 5. } 6. private void move() { 7. … 8. this.repaint(); 9. } 10. } 11.}

If the paintComponent method is misspelled, what happens? A.repaint works according to its specification. B.There is a runtime error message about a Null Pointer for the method. C.There is a compile time error message about not implementing a method for JPanel. D.The display looks fine until it is resized, or changes from covered to uncovered. [CORRECT] E.None of the above. More about repaint: 1.public class FishPanel extends javax.swing.JPanel{ public FishPanel(){ 4. … 5. } 6. private void move() { 7. … 8. this.repaint(); 9. } 10. } 11.}