Name Section. CS 21a Introduction to Computing I 1 st Semester Final Exam
|
|
- Bryan Phelps
- 6 years ago
- Views:
Transcription
1 CS a Introduction to Computing I st Semester Final Exam Write your name on each sheet. I. Multiple Choice. Encircle the letter of the best answer. ( points each) Answer questions and based on the following program: 0 public class MyApplet extends JApplet private JLabel mylabel; int age; public void init() Container c = this.getcontentpane(); c.setlayout( new FlowLayout() ); mylabel = new JLabel(); c.add( this.mylabel ); age = JOptionPane.showInputDialog( "Enter your age: "); mylabel.settext( "You are " + age + " years old.");. The above program should begin which of the following? a. import javax.swing.*; import java.awt.*; import java.awt.event.*; b. nothing; it s fine as it is c. import java.io.*; d. import javax.swing.*; import java.awt.*;. Which line will produce a compile-time error, assuming the necessary import lines have been added? a. b. c. d. Answer questions to based on the following program and its associated html file: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MultipleChoice extends JApplet implements ActionListener
2 private Panel question; private JTextArea questionarea; private Panel choicespanel; private JButton A, B, C, D; private JLabel labela, labelb, labelc, labeld; private Panel feedback; private JTextArea feedbackarea; public void init() Container c = this.getcontentpane(); c.setlayout( new BorderLayout() ); c.setbackground( Color.blue ); question = new Panel(); question.setlayout( new BorderLayout()); questionarea = new JTextArea(, 0); questionarea.settext( "0 + 0" ); question.add( "Center", questionarea ); question.add( "North", new JLabel( "Question:" ) ); choicespanel = new Panel(); choicespanel.setlayout( new GridLayout(,) ); A = new JButton( "A" ); B = new JButton( "B" ); C = new JButton( "C" ); D = new JButton( "D" ); labela = new JLabel( " 0" ); labelb = new JLabel( " 0" ); labelc = new JLabel( " 00" ); labeld = new JLabel( " 0" ); choicespanel.add( A ); choicespanel.add( labela ); choicespanel.add( new JLabel(" ") ); choicespanel.add( B ); choicespanel.add( labelb ); choicespanel.add( new JLabel(" ") ); choicespanel.add( C ); choicespanel.add( labelc ); choicespanel.add( new JLabel(" ") ); choicespanel.add( D ); choicespanel.add( labeld ); choicespanel.add( new JLabel(" ") ); A.addActionListener(this); B.addActionListener(this); C.addActionListener(this); D.addActionListener(this); feedback = new Panel(); feedback.setlayout( new BorderLayout()); feedback.add( "North", new JLabel( "Evaluation:" )); feedbackarea = new JTextArea(, 0 ); feedback.add( "Center", feedbackarea );
3 c.add( "North", question ); c.add( "Center", choicespanel ); c.add( "South", feedback ); public void actionperformed( ActionEvent ae ) Object temp; temp = ae.getsource(); if ( temp == A ) feedbackarea.settext( "Wrong answer!" ); else if ( temp == B ) feedbackarea.settext( "That's right!" ); else if ( temp == C ) feedbackarea.settext( "Sorry!" ); else if ( temp == D ) feedbackarea.settext( "Try again!" ); <APPLET CODE=MultipleChoice.class WIDTH=00 HEIGHT=00> </APPLET>. How does the applet look onscreen? a.
4 b. c.
5 d.. What are the dimensions of the applet? a. 00 pixels in height, 00 pixels in width b. 00 pixels in height, 00 pixels in width c. lines in height, 0 spaces in width d. 00 lines in height, 00 spaces in width. What are the contents of feedbackarea when the user clicks on 0? a. That s right! b. feedbackarea s contents do not change c. Wrong answer! d. Try again!. What elements are in the West portion of container c? a. A and C b. A, C, and Evaluation c. Question, questionarea, A, C, Evaluation, and feedbackarea d. none of the above. How many JLabels are there in container c? a. b. c. d. 0. Which of the following statements is TRUE? a. questionarea and feedbackarea are the same size b. questionarea is larger than feedbackarea c. feedbackarea is larger than questionarea d. the values of questionarea and feedbackarea cannot be changed
6 Answer questions to based on the code below: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DemoAppletNested extends JApplet implements ActionListener JTextField field; JTextArea area; JButton door; JButton door; public void init() field = new JTextField( 0 ); area = new JTextArea(, 0 ); door = new JButton( "Door " ); door = new JButton( "Door " ); JPanel door = new JPanel(); Container c = this.getcontentpane(); c.setlayout( new BorderLayout() ); c.add( new JLabel( "Type data in Text Field" ), "North" ); c.add( field, "South" ); c.add( door, "West" ); c.add( door, "East" ); door.setlayout( new FlowLayout() ); door.add( new JLabel( "Results" ) ); door.add( area ); c.add( door, "Center" ); door.addactionlistener( this ); door.addactionlistener( this ); public void actionperformed( ActionEvent ae ) Object temp; temp = ae.getsource(); if ( temp == door ) String s = field.gettext(); area.settext( s + "\n" + s ); else if ( temp == door ) String s = field.gettext(); int dollars = Integer.parseInt(s); int pesos = dollars*; area.settext( "Peso Conversion:" + pesos );
7 . What is the layout of the East region of container c? a. GridLayout b. FlowLayout c. BorderLayout d. None of the above 0. Where is the field located? a. Center region of c b. door panel c. South region of c d. actionlistener. If the user types 0 into the field and then clicks the Door button, what will appear in the area? a. 0 b. 0 0 c. Peso conversion: 0 Peso conversion: 0 d. Peso conversion: 0. Which of the following is TRUE about door and door a. They have the same height as the center region of c b. They have the same height as area c. They have the same width as door d. The have the same height as c. This screenshot illustrates which of the following? a. FlowLayout b. GridBagLayout c. BorderLayout d. CardLayout
8 . The screenshot illustrates which of the following? a. FlowLayout b. TabbedPane c. BoxLayout d. CardLayout. This screenshot illustrates which of the following? a. FlowLayout b. TabbedPane c. GridLayout d. BorderLayout
9 Answer questions to based on the following code: public class MyReader ArrayList<String> a; BufferedReader buf; public MyReader() a = new ArrayList<String>(); try buf = new BufferedReader( new FileReader( source.txt ) ); catch( Exception e) m.perform(); public void perform() try for( int i = 0; i < 00; i++ ) a[ i ] = s; catch( Exception e ) public static void main( String args[] ) MyReader m = new MyReader();. The above program should begin which of the following? a. import javax.swing.*; import java.awt.*; b. import javax.io.*; import java.awt.*; c. import java.util.*; d. import javax.util.*; import java.io.*;
10 . There is a line in the code that is incorrect. Which line is this? a. b. c. d.. The incorrect line should be replaced by which of the following statements? a. String s = buf.readfile(); b. buf = new BufferedReader( new Reader( source.txt ) ); c. a.add( s ); d. a.set(s);. If the textfile named source.txt does not exist, what will happen? a. A FileNotFoundException will be thrown and then the program will stop from its execution b. A FileNotFoundException will be thrown and the exception will be caught c. An ArrayIndexOutOfBounds exception will be thrown d. A NullPointerException will be thrown Assuming that the following code fragment works, answer questions 0, and.... ArrayList<String> a = new ArrayList<String>(); String s = "Hello"; String u = "Good Morning"; 0 String v = "Good Bye"; a.add( u ); a.add( v ); a.add( s ); for( int i = ; i > 0; i-- ) String temp = a.get( i ); System.out.print( temp + ); What will be printed out? a. Hello Good Morning b. Good Morning Goodbye Hello c. Hello Goodbye Good Morning d. Hello Goodbye 0
11 . Why is the integer i in line.not initialized to even if there are strings in the program? a. Initializing integer i to will cause a NullPointerException b. Initializing integer i to will cause an ArrayIndex OutOfBoundsException c. Not initializing i to will increase the speed of the iterations d. None of the above. One line in the code fragment should be replaced so that all strings will be displayed. This line should be replaced with which of the following statements? a. for( int i = ; i > 0; i++ ) b. for( int i = ; i >= 0; i++ ) c. for( int i > ; i > 0; i++ ) d. for( int i = ; i > 0; i++ ) Answer questions to based on the following code: public class Sample int[][] myarray; public Sample() myarray = new int[][]; populategrid(); hoparound(); public void populategrid() int element = ; for( int x = 0; x < ; x++ ) for( int y = 0; y < ; y++ ) myarray[ x ][ y ] = element; element = element*; public void hoparound() int q = ; for( int x = 0; x < ; x++ ) System.out.print( myarray[ x ][ q ] + " " );
12 0 0 if( q == 0 ) q = ; else q = 0; public static void main( String args[] ) Sample s = new Sample();. When this program is executed, what will be printed out? a. 0 b. 0 0 c. 0 d.. What will be the output if line was changed to int q = 0? a. b. 0 0 c. 0 d.. What will be the output of line was changed to int q =? a. ArrayIndexOutOfBoundsException b. NullPointerException c. IOException d. EOFException. What line should be modified to increase the number of columns? a. Line b. Line c. Line d. Line. Which lines should be replaced if you wanted to implement the exact code above with arraylists instead of arrays? a.,,, b.,,, c.,,, d.,,,. Line should be replaced with what line to use a one-dimensional arraylists? a. int myarraylist(); b. String myarraylist(); c. ArrayList<String> myarraylist(); d. ArrayList<int> myarraylist();
13 Answer numbers and 0 based on the code below: public class MultipleObjects Food[] f; public MultipleObjects() f = new Food[ ]; loadfood(); loadfood(); loadfood(); public void loadfood() Burger b = new Burger(); f[ 0 ]( b ); public void loadfood() Burger b = new Burger(); f[ ] = b; public void loadfood() Softdrink s = new Burger(); f[ ] = b; public static void main( String args[] ) MultipleObject m = new MultipleObjects(); public class Burger extends Food public Burger() System.out.println( "The burger lives!" );
14 public class Softdrink public Softdrink() System.out.println( "The burger lives!" ); 0 public class Food double price; public Food() public void setprice( double price ) this.price = price;. MultipleObjects.java has erroneous lines of code. Which of the following cause the errors? a. The constructor MultipleObjects.java b. The loadfood() method c. The loadfood() method d. The loadfood() method 0. Which methods and attributes of Food will the Softdrink object inherit? a. Softdrink object will not inherit anything b. Softdrink object will inherit the price attribute only c. Softdrink object will inherit the price attribute and setprice() method d. Softdrink object will inherit the setprice() method only
15 Answer questions to based on the following code: public class Animal private String name; public Animal() name = "Nameless"; public Animal( String s ) name = s; public String getname() return name; public void makesound() System.out.println( "ZZZ.." ); public class Dog extends Animal private int numbarks; public Dog( int n ) numbarks = n; public Dog( String n ) super( n ); numbarks = ; public void makesound() for( int i = 0; i < numbarks; i++ ) System.out.println( "" ); public class Cat extends Animal public Cat( String s ) super( s ); // # public void scratch() System.out.println( "Scratch" );
16 . Which of the following methods is overridden by a subclass? a. getname() b. makesound() c. scratch() d. super(). Suppose Cat c = new Cat( Felix );, what output will result from the statement c.makesound(); a. ZZZ b. c. d. Scratch. Suppose Animal d = new Dog( Spot );, what output will result from the statement d.makesound(); a. ZZZ b. c. d. Scratch. Suppose Dog d = new Dog( );, what output will result from the statements System.out.println( d.getname() ); d.makesound(); a. b. c. Nameless d. Nameless. If the call to super( s ); in the Cat class is removed, a. The code will not compile successfully b. All Cat objects will be have the name Nameless c. There will be no superclass constructor invoked d. None of the above
17 For numbers -, consider the folowing snippet of code: 0 public void readfile() try /* [#] code to print out contents of * "classlist.txt" to "classlist-copy.txt" */ catch( FileNotFoundException fnfe ) fnfe.printstacktrace(); catch( [#] ex ) ex.printstacktrace();. To print out the contents of the file "classlist.txt" to another file called "classlist-copy.txt", which of the following lines can be used? i. BufferedReader reader = new BufferedReader( new InputStreamReader( "classlist.txt" ) ); ii. BufferedReader reader = new BufferedReader( new FileReader( "classlist.txt" ) ); iii. PrintStream printer = new PrintStream( new FileOutputStream( "classlist.txt" ) ); iv. PrintStream printer = new PrintStream( new BufferedWriter( "classlist-copy.txt" ) ); a. i and iii b. ii and iii c. ii and iv d. None of the above. If "classlist.txt" is deleted from the computer and the application is run, which code is executed? a. fnfe.printstacktrace() b. ex.printstacktrace() c. Both a and b: the code will throw two exceptions d. None of the above: the code will not throw any exceptions
18 . If the programmer chooses not to catch exceptions, he/she must a. Use FileInputStream and FileOutputStream, classes which do not throw exceptions b. Call reader.close() and printer.close() to make sure exceptions are closed c. Declare that exceptions will be thrown by the method d. Compile the program using the "javap" command to solve the problem. To catch all other exceptions related to files, line must catch a. BufferedIOException b. FileException c. EOFException d. IOException 0. In order to use a Canvas, a class must a. Extend Canvas and override the paint() method b. Extend Canvas and override the draw() method c. Execute this = Canvas.getCanvas() to assign the class to a Canvas d. Execute Graphics g = new Graphics() to draw using "g" For the numbers -, consider the following snippet of code: 0 0 int a, b; public void draw( Graphics g ) int result = a * b % ; Color mycolor; switch( result ) case 0: mycolor = Color.YELLOW; case : mycolor = Color.BLUE; case : mycolor = Color.RED; default: mycolor = Color.BLACK; g.setcolor( mycolor ); g.fillrect( 0, 0, 0, 0 );. If a = and b =, calling this method would draw a a. Filled yellow rectangle b. Filled blue rectangle c. Filled red rectangle d. Filled black rectangle
19 . If a = and b =, calling this method would draw a a. Filled yellow rectangle b. Filled blue rectangle c. Filled red rectangle d. Filled black rectangle. To draw a hollow circle instead, line must be changed to a. g.fillrect( 0, 0, 0, 0, false ); b. g.drawcircle( 0, 0, 0, 0 ); c. g.drawoval( 0, 0, 0, 0 ); d. g.fillcircle( 0, 0, 0, 0, false );. Which of the following is NOT a benefit of encapsulating shapes? a. It is easier to display similar shapes in the canvas b. Shapes can override each other c. The code is shorter and more organized d. Can use arrays or ArrayLists and inheritance to maintain the different shape objects. Which of the following is true? a. A stream is a sequence of bytes and/or characters b. Applets can read and write to text files c. An uncaught exception will always result in a compile error d. If you want to update the file without closing it yet, you can call the update() method II. True or False ( point each). Static fields are shared by all instances of the same class.. The parameter of the main method of a Java application is an array.. All exceptions thrown in a Java program have to be caught.. Arrays are objects.. flush() is a method of the PrintStream class.. setlayout() is a method of the Container class.. addactionlistener() is a method of the ActionEvent class.. JApplet is a subclass of JFrame.. Subclass variables can refer to objects of its superclass. 0. All private methods of a class can be accessed from its subclasses.
First Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: JSP Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More informationFirst Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: Standard Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More informationIntroduction This assignment will ask that you write a simple graphical user interface (GUI).
Computing and Information Systems/Creative Computing University of London International Programmes 2910220: Graphical Object-Oriented and Internet programming in Java Coursework one 2011-12 Introduction
More informationVirtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.
1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program
More informationFull file at Chapter 2 - Inheritance and Exception Handling
Chapter 2 - Inheritance and Exception Handling TRUE/FALSE 1. The superclass inherits all its properties from the subclass. ANS: F PTS: 1 REF: 76 2. Private members of a superclass can be accessed by a
More informationCS 180 Final Exam Review 12/(11, 12)/08
CS 180 Final Exam Review 12/(11, 12)/08 Announcements Final Exam Thursday, 18 th December, 10:20 am 12:20 pm in PHYS 112 Format 30 multiple choice questions 5 programming questions More stress on topics
More informationCommand-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.
1 CS257 Computer Science I Kevin Sahr, PhD Lecture 14: Graphical User Interfaces Command-Line Applications 2 The programs we've explored thus far have been text-based applications A Java application is
More informationJava Programming Lecture 6
Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components
More informationCome & Join Us at VUSTUDENTS.net
Come & Join Us at VUSTUDENTS.net For Assignment Solution, GDB, Online Quizzes, Helping Study material, Past Solved Papers, Solved MCQs, Current Papers, E-Books & more. Go to http://www.vustudents.net and
More informationCS 180 Fall 2006 Exam II
CS 180 Fall 2006 Exam II There are 20 multiple choice questions. Each one is worth 2 points. There are 3 programming questions worth a total of 60 points. Answer the multiple choice questions on the bubble
More informationCONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13
CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling
More informationThis exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.
York University AS/AK/ITEC 2610 3.0 All Sections OBJECT-ORIENTED PROGRAMMING Midterm Test Duration: 90 Minutes This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for
More informationWelcome to CIS 068! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) CIS 068
Welcome to! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) Overview JAVA and GUIs: SWING Container, Components, Layouts Using SWING Streams and Files Text
More informationFinal Examination Semester 2 / Year 2011
Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2011 COURSE COURSE CODE TIME DEPARTMENT LECTURER : JAVA PROGRAMMING : PROG1114 : 2 1/2 HOURS : COMPUTER SCIENCE : LIM PEI GEOK Student
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 5 problems on the following 7 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet
More informationCourse Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski
CS 190 - Java Introduction to Java Andy Mroczkowski uamroczk@cs.drexel.edu Department of Computer Science Drexel University March 10, 2008 / Lecture 8 Outline Course Status Course Information & Schedule
More informationTopic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"
More informationTopic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques
More informationContents Chapter 1 Introduction to Programming and the Java Language
Chapter 1 Introduction to Programming and the Java Language 1.1 Basic Computer Concepts 5 1.1.1 Hardware 5 1.1.2 Operating Systems 8 1.1.3 Application Software 9 1.1.4 Computer Networks and the Internet
More informationCS 3331 Advanced Object-Oriented Programming Final Exam
Fall 2015 (Thursday, December 3) Name: CS 3331 Advanced Object-Oriented Programming Final Exam This test has 5 questions and pages numbered 1 through 10. Reminders This test is closed-notes and closed-book.
More informationAP CS Unit 11: Graphics and Events
AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two
More informationOutline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics
Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming
More informationCS 209 Programming in Java #10 Exception Handling
CS 209 Programming in Java #10 Exception Handling Textbook Chapter 15 Spring, 2006 Instructor: J.G. Neal 1 Topics What is an Exception? Exception Handling Fundamentals Errors and Exceptions The try-catch-finally
More informationJava Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application
Last Time v We created our first Java application v What are the components of a basic Java application? v What GUI component did we use in the examples? v How do we write to the standard output? v An
More informationCS 11 java track: lecture 3
CS 11 java track: lecture 3 This week: documentation (javadoc) exception handling more on object-oriented programming (OOP) inheritance and polymorphism abstract classes and interfaces graphical user interfaces
More informationStarting Out with Java: From Control Structures Through Objects Sixth Edition
Starting Out with Java: From Control Structures Through Objects Sixth Edition Chapter 12 A First Look at GUI Applications Chapter Topics 12.1 Introduction 12.2 Creating Windows 12.3 Equipping GUI Classes
More informationSample Examination Paper Programming and Software Development
THE UNIVERSITY OF MELBOURNE DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Sample Examination Paper 2008 433-520 Programming and Software Development Exam Duration: 2 hours Total marks for this
More informationExample: Building a Java GUI
Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate
More informationJava - Applets. public class Buttons extends Applet implements ActionListener
Java - Applets Java code here will not use swing but will support the 1.1 event model. Legacy code from the 1.0 event model will not be used. This code sets up a button to be pushed: import java.applet.*;
More informationJava Just in Time: Collected concepts after chapter 18
Java Just in Time: Collected concepts after chapter 18 John Latham, School of Computer Science, Manchester University, UK. April 15, 2011 Contents 1 Computer basics 18000 1.1 Computer basics: hardware
More informationExample: Building a Java GUI
Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate
More informationGraphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI
CBOP3203 Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI components like button, text input, scroll bar and others.
More informationJava Just in Time: Collected concepts after chapter 22
Java Just in Time: Collected concepts after chapter 22 John Latham, School of Computer Science, Manchester University, UK. April 15, 2011 Contents 1 Computer basics 22000 1.1 Computer basics: hardware
More informationCSSE 220 Day 19. Object-Oriented Design Files & Exceptions. Check out FilesAndExceptions from SVN
CSSE 220 Day 19 Object-Oriented Design Files & Exceptions Check out FilesAndExceptions from SVN A practical technique OBJECT-ORIENTED DESIGN Object-Oriented Design We won t use full-scale, formal methodologies
More informationMultiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)
M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but
More informationUniversity of Cape Town Department of Computer Science. Computer Science CSC117F Solutions
University of Cape Town Department of Computer Science Computer Science CSC117F Solutions Class Test 4 Wednesday 14 May 2003 Marks: 40 Approximate marks per question are shown in brackets Time: 40 minutes
More informationChapter 12 Advanced GUIs and Graphics
Chapter 12 Advanced GUIs and Graphics Chapter Objectives Learn about applets Explore the class Graphics Learn about the classfont Explore the classcolor Java Programming: From Problem Analysis to Program
More informationJava Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing
Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/uiswing/toc.html http://www.unix.org.ua/orelly/java-ent/jfc/
More informationCSSE 220 Day 19. Object-Oriented Design Files & Exceptions. Check out FilesAndExceptions from SVN
CSSE 220 Day 19 Object-Oriented Design Files & Exceptions Check out FilesAndExceptions from SVN A practical technique OBJECT-ORIENTED DESIGN Object-Oriented Design We won t use full-scale, formal methodologies
More informationJava. GUI building with the AWT
Java GUI building with the AWT AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses the controls defined by your OS therefore
More informationParts of a Contract. Contract Example. Interface as a Contract. Wednesday, January 30, 13. Postcondition. Preconditions.
Parts of a Contract Syntax - Method signature Method name Parameter list Return type Semantics - Comments Preconditions: requirements placed on the caller Postconditions: what the method modifies and/or
More informationPART1: Choose the correct answer and write it on the answer sheet:
PART1: Choose the correct answer and write it on the answer sheet: (15 marks 20 minutes) 1. Which of the following is included in Java SDK? a. Java interpreter c. Java disassembler b. Java debugger d.
More informationIntroduction. Introduction
Introduction Many Java application use a graphical user interface or GUI (pronounced gooey ). A GUI is a graphical window or windows that provide interaction with the user. GUI s accept input from: the
More informationCS 2113 Software Engineering
CS 2113 Software Engineering Java 5 - GUIs Import the code to intellij https://github.com/cs2113f18/template-j-5.git Professor Tim Wood - The George Washington University Class Hierarchies Abstract Classes
More informationTable of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...
Table of Contents Chapter 1 Getting Started with Java SE 7 1 Introduction of Java SE 7... 2 Exploring the Features of Java... 3 Exploring Features of Java SE 7... 4 Introducing Java Environment... 5 Explaining
More informationRAIK 183H Examination 2 Solution. November 10, 2014
RAIK 183H Examination 2 Solution November 10, 2014 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)
More informationMIT AITI Swing Event Model Lecture 17
MIT AITI 2004 Swing Event Model Lecture 17 The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the user. But how do GUIs interact with users? How do applications
More informationIntroduction to the JAVA UI classes Advanced HCI IAT351
Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing
More informationBuilding a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver
Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components
More informationprotected void printserial() { System.out.println("> NO." + this.serialno); this.serialno++; }
NumberedTicketGenerator.java package j2.exam.ex01; public abstract class NumberedTicketGenerator { protected int serialno; public NumberedTicketGenerator() { super(); this.serialno = 1000; public void
More informationCSE Lab 8 Assignment Note: This is the last lab for CSE 1341
CSE 1341 - Lab 8 Assignment Note: This is the last lab for CSE 1341 Pre-Lab : There is no pre-lab this week. Lab (100 points) The objective of Lab 8 is to get familiar with and utilize the wealth of Java
More informationWe are on the GUI fast track path
We are on the GUI fast track path Chapter 13: Exception Handling Skip for now Chapter 14: Abstract Classes and Interfaces Sections 1 9: ActionListener interface Chapter 15: Graphics Skip for now Chapter
More informationProgramming - 2. Common Errors
Common Errors There are certain common errors and exceptions which beginners come across and find them very annoying. Here we will discuss these and give a little explanation of what s going wrong and
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2011 FINAL EXAMINATION 7pm to 10pm, 26 APRIL 2011, Ross Gym Instructor: Alan McLeod If the instructor
More informationCS180 Spring 2010 Exam 2 Solutions, 29 March, 2010 Prof. Chris Clifton
CS180 Spring 2010 Exam 2 Solutions, 29 March, 2010 Prof. Chris Clifton Turn Off Your Cell Phone. Use of any electronic device during the test is prohibited. Time will be tight. If you spend more than the
More informationFinal Examination Semester 2 / Year 2012
Final Examination Semester 2 / Year 2012 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. : Notes to candidates:
More informationWindow Interfaces Using Swing Objects
Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs
More informationSE1021 Exam 2. When returning your exam, place your note-sheet on top. Page 1: This cover. Page 2 (Multiple choice): 10pts
SE1021 Exam 2 Name: You may use a note-sheet for this exam. But all answers should be your own, not from slides or text. Review all questions before you get started. The exam is printed single-sided. Write
More informationWhat is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs
What is Widget Layout? Laying Out Components Positioning widgets in their container (typically a JPanel or a JFrame s content pane) Basic idea: each widget has a size and position Main problem: what if
More informationRAIK 183H Examination 2 Solution. November 11, 2013
RAIK 183H Examination 2 Solution November 11, 2013 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)
More informationI pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.
Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone
More informationPart 3: Graphical User Interface (GUI) & Java Applets
1,QWURGXFWLRQWR-DYD3URJUDPPLQJ (( Part 3: Graphical User Interface (GUI) & Java Applets EE905-GUI 7RSLFV Creating a Window Panels Event Handling Swing GUI Components ƒ Layout Management ƒ Text Field ƒ
More informationIntroduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008
Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Announcements A3 is up, due Friday, Oct 10 Prelim 1 scheduled for Oct 16 if you have a conflict, let us know now 2 Interactive
More informationLecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:
Lecture 28 Exceptions and Inner Classes Goals We are going to talk in more detail about two advanced Java features: Exceptions supply Java s error handling mechanism. Inner classes ease the overhead of
More informationAn array is a type of variable that is able to hold more than one piece of information under a single variable name.
Arrays An array is a type of variable that is able to hold more than one piece of information under a single variable name. Basically you are sub-dividing a memory box into many numbered slots that can
More informationJAVA Programming Language Homework VI: Threads & I/O
JAVA Programming Language Homework VI: Threads & I/O ID: Name: 1. When comparing java.io.bufferedwriter to java.io.filewriter, which capability exists as a method in only one of the two? A. Closing the
More information8. Polymorphism and Inheritance
8. Polymorphism and Inheritance Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives Describe polymorphism and inheritance in general Define interfaces
More informationWindow Interfaces Using Swing Objects
Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs
More informationFrames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling
Frames, GUI and events Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Introduction to Swing The Java AWT (Abstract Window Toolkit)
More informationPackages: Putting Classes Together
Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic
More informationF I N A L E X A M I N A T I O N
Faculty Of Computer Studies M257 Putting Java to Work F I N A L E X A M I N A T I O N Number of Exam Pages: (including this cover sheet( Spring 2011 April 4, 2011 ( 5 ) Time Allowed: ( 1.5 ) Hours Student
More informationAgenda. Container and Component
Agenda Types of GUI classes/objects Step-by-step guide to create a graphic user interface Step-by-step guide to event-handling PS5 Problem 1 PS5 Problem 2 Container and Component There are two types of
More informationJava for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.
Java for Non Majors Final Study Guide April 26, 2017 The test consists of 1. Multiple choice questions 2. Given code, find the output 3. Code writing questions 4. Code debugging question 5. Short answer
More informationCS Exam 3 - Spring 2010
CS 1316 - Exam 3 - Spring 2010 Name: Grading TA: Section: INTEGRITY: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014 Name: This exam consists of 5 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet
More informationSystems Programming Graphical User Interfaces
Systems Programming Graphical User Interfaces Julio Villena Román (LECTURER) CONTENTS ARE MOSTLY BASED ON THE WORK BY: José Jesús García Rueda Systems Programming GUIs based on Java
More informationLab & Assignment 1. Lecture 3: ArrayList & Standard Java Graphics. Random Number Generator. Read Lab & Assignment Before Lab Wednesday!
Lab & Assignment 1 Lecture 3: ArrayList & Standard Java Graphics CS 62 Fall 2015 Kim Bruce & Michael Bannister Strip with 12 squares & 5 silver dollars placed randomly on the board. Move silver dollars
More informationGraphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)
Graphics programming COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson) Overview Aims To provide an overview of Swing and the AWT To show how to build
More informationFinal Examination Semester 3 / Year 2008
Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2008 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE CLASS : CS08-A + CS08-B LECTURER
More informationMidterm assessment - MAKEUP Fall 2010
M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:
More informationLecture 5: Java Graphics
Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, FALL TERM, 2013 FINAL EXAMINATION 7pm to 10pm, 18 DECEMBER 2013 Instructor: Alan McLeod If the instructor
More informationTo gain experience using GUI components and listeners.
Lab 5 Handout 7 CSCI 134: Fall, 2017 TextPlay Objective To gain experience using GUI components and listeners. Note 1: You may work with a partner on this lab. If you do, turn in only one lab with both
More informationJava Help Files. by Peter Lavin. May 22, 2004
Java Help Files by Peter Lavin May 22, 2004 Overview Help screens are a necessity for making any application user-friendly. This article will show how the JEditorPane and JFrame classes, along with HTML
More informationLaying Out Components. What is Widget Layout?
Laying Out Components Interior Design for GUIs What is Widget Layout? Positioning widgets in their container (typically a JPanel or a JFrame s content pane) Basic idea: each widget has a size and position
More informationName: Checked: Learn about listeners, events, and simple animation for interactive graphical user interfaces.
Lab 15 Name: Checked: Objectives: Learn about listeners, events, and simple animation for interactive graphical user interfaces. Files: http://www.csc.villanova.edu/~map/1051/chap04/smilingface.java http://www.csc.villanova.edu/~map/1051/chap04/smilingfacepanel.java
More informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,
More informationJRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();
Q)Write a program to design an interface containing fields User ID, Password and Account type, and buttons login, cancel, edit by mixing border layout and flow layout. Add events handling to the button
More informationFinal Exam CS 251, Intermediate Programming December 13, 2017
Final Exam CS 251, Intermediate Programming December 13, 2017 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible
More information+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage)
+! Lecture 3: ArrayList & Standard Java Graphics +! Today n Reading n Standard Java Graphics (on course webpage) n Objectives n Review for this week s lab and homework assignment n Miscellanea (Random,
More informationJava - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,
Java - Applets C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1, 5.3.2. Java is not confined to a DOS environment. It can run with buttons and boxes in a Windows
More informationLayouts and Components Exam
Layouts and Components Exam Name Period A. Vocabulary: Answer each question specifically, based on what was taught in class. Term Question Answer JScrollBar(a, b, c, d, e) Describe c. ChangeEvent What
More informationProgramming: You will have 6 files all need to be located in the dir. named PA4:
PROGRAMMING ASSIGNMENT 4: Read Savitch: Chapter 7 and class notes Programming: You will have 6 files all need to be located in the dir. named PA4: PA4.java ShapeP4.java PointP4.java CircleP4.java RectangleP4.java
More informationThe Islamic University Gaza Department of Electrical & Computer Engineering. Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324
The Islamic University Gaza Department of Electrical & Computer Engineering Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324 Instructor: Dipl.-Ing. Abdelnasser Abdelhadi Date: 31.03.2013
More informationProgramming graphics
Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it
More informationFinal Examination Semester 2 / Year 2010
Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student
More informationObject Oriented Design. Object-Oriented Design. Inheritance & Polymorphism. Class Hierarchy. Goals Robustness Adaptability Flexible code reuse
Object-Oriented Design Object Oriented Design Goals Robustness Adaptability Flexible code reuse Principles Abstraction Encapsulation Modularity March 2005 Object Oriented Design 1 March 2005 Object Oriented
More informationCOMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) )
COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) ) Course Evaluations Please do these. -Fast to do -Used to
More informationThe Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).
The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,
More informationSyllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE0403. B.Tech. Year - II
Subject Code: 01CE0403 Subject Name: Object Oriented Programming with Java B.Tech. Year - II Objective: Java is a computer programming language having feature like objectoriented, polymorphism, inheritance
More information