Final Examination Semester 2 / Year 2011

Size: px
Start display at page:

Download "Final Examination Semester 2 / Year 2011"

Transcription

1 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 s ID Batch No. : : Notes to candidates: 1) The question paper consists of 8 pages Section A: 10 questions (20 marks) Section B: 2 questions (20 marks) Section C: 2 questions (60 marks) 2) Answer all questions. 3) Write your answer for Section A and Section B in answer booklet. 4) Save your answer for question in Section C and submit your answer in softcopy to Southern College E-Learning System.

2 SECTION A: MULTIPLE CHOICE QUESTION (10 X 2 = 20 MARKS) Please choose most appropriate answer. State the answer in the answer booklet. 1. A class, method or data is accessible to all clients. A method or data is only accessible inside the class. a. public, private b. public, protected c. private, public d. none, none 2. Identify which of the following is the concept of constructors? a. Constructors of superclass are inherited in the subclass. b. The return type of constructor is void. c. Constructor is invoke using the new operator when an object is created. d. A constructor called default constructor is provided automatically for all classes. 3. Which of the following is NOT a reserved word in Java? a. constant b. double c. class d. final 4. Which of the following method use to return a new String object that remove all white-space character in the String s? a. s.remove() b. s.trim() c. s.remove(, ) d. s.trim(, ) 5. Which of the following is a NOT javax.swing component? a. JLabel b. JPanel c. JFrame d. Button 6. Which of the following is not a method of class JTextField? a. addactionlistener b. settext c. setvisible d. seteditable 7. Which of the following is NOT kind of layout manager? a. GridLayout b. BorderLayout c. FlowLayout d. TableLayout 1/7

3 8. Which of the following is NOT correct about the Graphics components? a. Each component has its own coordinate system with the origin (0,0). b. The coordinate system located at the upper-right corner of the window. c. Import the java.awt.graphics to draw the graphics components such as polygon, rectangles and so on. d. Override the paintcomponent method to tell the container how to draw things. 9. Which of the following events will be trigger if mouse is pressed, released, clicked, entered and exited? a. addmousemotionlistener() b. addactionlistener() c. MouseExited() d. MouseClose() 10. Which of the following method is used to catch an error that occurs when opening a file? a. OpenFileException b. FileException c. FileOpenException d. IOException 2/7

4 SECTION B: SHORT QUESTIONS (20 MARKS) Question 1 (12 Marks) a) What is displayed on the console when the following program is executed? (4 Marks) public static void main(string[] args) { String s1 = new String("Thank you"); String s2 = thank you"; if(s1.equals(s2)){ System.out.println("s1 and s2 have the same content"); else{ System.out.println("s1 and s2 do not have the same content"); if(s1 == s2){ System.out.println("s1 and s2 have the same reference"); else{ System.out.println("s1 and s2 do not have the same reference"); b) What is the output for the following codes? (You no need to show the actual position of the graphic components. You just need to sketch out what is display and how it look like when the following codes is executed.) (4 Marks) import javax.swing.*; import java.awt.*; public class DrawGraphic extends JPanel{ public static void main(string[] args) { JFrame frame = new JFrame("Draw Graphic"); frame.add(new DrawGraphic()); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setsize(300, 200); frame.setvisible(true); protected void paintcomponent(graphics g) { super.paintcomponent(g); g.drawrect(10,10, 110,110); g.drawstring(""good luck!", 40, 60); 3/7

5 c) Show the output for the following program. (4 Marks) public static void main (String[] args) { String s = "Hello+!Nice+to-meet+you."; StringTokenizer st = new StringTokenizer(s, "+!"); while (st.hasmoretokens()){ System.out.println(st.nextToken() + " "); Question 2 (8 Marks) a. Suppose that s1 and s2 are two Strings. Which of the following statements or expression are incorrect? State the line number of the incorrect statements or expression. (3 Marks) 1 String s = new String( new string ); 2 String s3 = s1 + s2; 3 String s4 = s1 s2; 4 s1 == s2 5 s1 >= s2 6 int i = s1.length(); 7 char c = s1(0); b. There are two errors in the following classes. Identify the problems and rewrite the statement with correct codes. (5 Marks). 1 class Rectangle{ 2 private double length; 3 private double width; 4 public Rectangle(double length, double width){ 5 this.length = length; 6 this.width = width; 7 8 double findarea(){ 9 return length * width; class Box extends Rectangle{ 12 private double height; 13 public double findarea(){ 14 return findarea()*height; public Box(double length, double width ){ 17 Rectangle(length, width); /7

6 SECTION C: CODING QUESTIONS (60 MARKS) Submit your answer in softcopy and upload it to Southern E-Learning System. Question 1 (25 Marks) Design a class named FixedInvestment contains: (1 Mark) a) A double data field name depositamount that specifies the investment amount (default 1000). (1 Mark) b) A double data field name annualinterestrate that specifies the fixed interest rate (default 5%). (1 Mark) c) An int data field named numberofyears that specifies the investment duration (default 1). (1 Mark) d) A no-arg constructor that creates a default instance. (2 Marks) e) A constructor that creates an instance with the specified depositamount, annualinterestrate and numberofyears. (4 Marks) f) The accessor methods for depositamount, numberofyears, and annualinterestrate. (3 Marks) g) The mutator method for numberofyears. (1 Mark) h) A method named gettotalreturn() that returns the investment return after the specified number of years. (6 Marks) The total return can be computed using the following formula: numberofyears * 12 totalreturn = investmentamount x (1 + montlyinterestrate) Write a test program named as TestFixedInvestment that creates a FixedInvestment object with a deposit amount of and an annual interest rate of 8.5% for 5 years. Your program is then display the investment return for the year 1 to year 5 based on the investment duration. The output as follow: (5 Mark) Years Investment return Question 2(35 Marks) Write a program to perform account registration. This account registration system requires the bank staff to enter the customer account number, first name, last name and the balance. The system should able to check the user input to ensure that the correct information was entered by the bank staff user. The account number should only consist of integer value and the balance should be a double value. The bank staff can click the Save to File button to save the account record to a file. You need to complete the following specifications: a) Create a user interface as show in figure 1. (10 Marks) 5/7

7 b) Write the exception handler to handle the number format of account number and balance. You need to display the error message as show in figure 2 when it is appropriate. (5 Marks) c) Save the customer information which include account number, first name, last name and balance into a file when user click on Save to File button. The name of the file should be same as the account number such as txt for account The format of file should same as the output as show in figure 3. (12 Mark) d) You are required to write a status message to tell the user about the records saving status. The message Records was save successfully! when the records was saved successfully into the file. The message Duplicate account number is not allowed! is shown when the same account number exists. If this case happened, user will stop the process and display the error message. Figure 4 and 5 show the example output of error message. (8 Marks). Figure 1: User interface Figure 2: Dialog box is displayed when user entered incorrect number format either on account number or balance textfields. 6/7

8 Figure 3: Output of record.txt file. Figure 4: Example of status message when file was saved sucessfully. Figure 5: Example of status message when the account number was duplicated /7

Final Examination Semester 2 / Year 2012

Final 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 information

Final Examination Semester 2 / Year 2010

Final 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 information

Final Examination Semester 3 / Year 2012

Final Examination Semester 3 / Year 2012 Final Examination Semester 3 / Year 2012 COURSE : OBJECT-ORIENTED PROGRAMMING COURSE CODE : PROG 2013 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. :

More information

Final Examination Semester 3 / Year 2008

Final 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 information

Final Examination Semester 3 / Year 2012

Final Examination Semester 3 / Year 2012 Final Examination Semester 3 / Year 2012 COURSE : ADVANCED JAVA PROGRAMMING COURSE CODE : PROG 2114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. : Notes

More information

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2010 COURSE : OBJECT-ORIENTED PROGRAMMING COURSE CODE : PROG 2013 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM

More information

Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2011 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2011 COURSE : FUNDAMENTALS OF SOFTWARE DESIGEN AND DEVELOPMENT COURSE CODE : PROG1003 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE

More information

Final Examination Semester 3 / Year 2007

Final Examination Semester 3 / Year 2007 Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2007 COURSE : FUNDAMENTALS OF SOFTWARE DESIGN AND DEVELOPMENT COURSE CODE : PROG1003 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE

More information

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2010 COURSE : INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING COURSE CODE : CCIS1103 TIME : 3 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : VISUAL BASIC.NET COURSE CODE : PROG2024 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student

More information

Final Examination Semester 3 / Year 2012

Final Examination Semester 3 / Year 2012 Final Examination Semester 3 / Year 2012 COURSE : INTRODUCTION TO PROGRAMMING COURSE CODE : PROG1013 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. :

More information

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2010 COURSE : PROGRAMMING LOGIC AND DESIGN COURSE CODE : CCIS1003 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM

More information

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : PROGRAMMING LOGIC AND DESIGN COURSE CODE : CCIS1003 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM

More information

H212 Introduction to Software Systems Honors

H212 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 information

Introduction This assignment will ask that you write a simple graphical user interface (GUI).

Introduction 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 information

Graphic User Interfaces. - GUI concepts - Swing - AWT

Graphic User Interfaces. - GUI concepts - Swing - AWT Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations

More information

Final Examination Semester 1 / Year 2011

Final Examination Semester 1 / Year 2011 Southern College Kolej Selatan 南方学院 Final Examination Semester 1 / Year 2011 COURSE : DATA STRUCTURE AND ALGORITHM COURSE CODE : PROG2103 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : SO

More information

Name Section. CS 21a Introduction to Computing I 1 st Semester Final Exam

Name Section. CS 21a Introduction to Computing I 1 st Semester Final Exam CS a Introduction to Computing I st Semester 00-00 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

More information

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I Electrical and Computer Engineering Object-Oriented Topic : Graphics GUI Part I Maj Joel Young Joel.Young@afit.edu 15-Sep-03 Maj Joel Young A Brief History Lesson AWT Abstract Window Toolkit Implemented

More information

Assignment 2. Application Development

Assignment 2. Application Development Application Development Assignment 2 Content Application Development Day 2 Lecture The lecture covers the key language elements of the Java programming language. You are introduced to numerical data and

More information

MIT AITI Swing Event Model Lecture 17

MIT 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 information

UNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering

UNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering UNIVERSITI SAINS MALAYSIA First Semester Examination Academic Session 2003/2004 September/October 2003 CIT502 Object-Oriented Programming and Software Engineering Duration : 3 hours INSTRUCTION TO CANDIDATE:

More information

Instruction to students:

Instruction to students: Benha University 2 nd Term (2012) Final Exam Class: 2 nd Year Students Subject: Object Oriented Programming Faculty of Computers & Informatics Date: 20/5/2012 Time: 3 hours Examiner: Dr. Essam Halim Instruction

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan

More information

First Name: AITI 2004: Exam 2 July 19, 2004

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 information

University of Cape Town Department of Computer Science. Computer Science CSC117F Solutions

University 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 information

Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2011 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2011 COURSE : COMPUTER SYSTEM COURSE CODE : CSIS 1003 TIME : 2 HOURS 30 MINUTES DEPARTMENT : COMPUTER SCIENCE LECTURER : DR. LEE

More information

Introduction to the JAVA UI classes Advanced HCI IAT351

Introduction 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 information

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

Graphical User Interfaces. Comp 152

Graphical User Interfaces. Comp 152 Graphical User Interfaces Comp 152 Procedural programming Execute line of code at a time Allowing for selection and repetition Call one function and then another. Can trace program execution on paper from

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors 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 information

Java Programming Lecture 6

Java 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 information

Chapter 12 Advanced GUIs and Graphics

Chapter 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 information

CSE wi Final Exam 3/12/18 Sample Solution

CSE wi Final Exam 3/12/18 Sample Solution Question 1. (8 points, 2 each) Equality. Recall that there are several different notions of object equality that we ve encountered this quarter. In particular, we have the following three: Reference equality:

More information

Midterm assessment - MAKEUP Fall 2010

Midterm 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 information

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

JRadioButton 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 information

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in Lab 4 D0010E Object-Oriented Programming and Design Lecture 9 Lab 4: You will implement a game that can be played over the Internet. The networking part has already been written. Among other things, the

More information

Graphics User Defined Forms, Part I

Graphics User Defined Forms, Part I Graphics User Defined Forms, Part I Quick Start Compile step once always mkdir labs javac PropertyTax5.java cd labs mkdir 5 Execute step cd 5 java PropertyTax5 cp /samples/csc/156/labs/5/*. cp PropertyTax1.java

More information

2. (True/False) All methods in an interface must be declared public.

2. (True/False) All methods in an interface must be declared public. Object and Classes 1. Create a class Rectangle that represents a rectangular region of the plane. A rectangle should be described using four integers: two represent the coordinates of the upper left corner

More information

TTTK Program Design and Problem Solving Tutorial 3 (GUI & Event Handlings)

TTTK Program Design and Problem Solving Tutorial 3 (GUI & Event Handlings) TTTK1143 - Program Design and Problem Solving Tutorial 3 (GUI & Event Handlings) Topic: JApplet and ContentPane. 1. Complete the following class to create a Java Applet whose pane s background color is

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) Layout Managment 1 Hello World Often have a static method: createandshowgui() Invoked by main calling invokelater private static void createandshowgui() { } JFrame frame

More information

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008 Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object

More information

First Name: AITI 2004: Exam 2 July 19, 2004

First 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 information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:

More information

Window Interfaces Using Swing Objects

Window 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 information

GUI and its COmponent Textfield, Button & Label. By Iqtidar Ali

GUI and its COmponent Textfield, Button & Label. By Iqtidar Ali GUI and its COmponent Textfield, Button & Label By Iqtidar Ali GUI (Graphical User Interface) GUI is a visual interface to a program. GUI are built from GUI components. A GUI component is an object with

More information

Window Interfaces Using Swing Objects

Window 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 information

We are on the GUI fast track path

We 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 information

Packages: Putting Classes Together

Packages: 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 information

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components CS112-Section2 Hakan Guldas Burcin Ozcan Meltem Kaya Muge Celiktas Notes of 6-8 May Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how

More information

PIC 20A GUI with swing

PIC 20A GUI with swing PIC 20A GUI with swing Ernest Ryu UCLA Mathematics Last edited: November 22, 2017 Hello swing Let s create a JFrame. import javax. swing.*; public class Test { public static void main ( String [] args

More information

Frames, 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 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 information

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

Multiple 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 information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview

More information

AP CS Unit 11: Graphics and Events

AP 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 information

AP CS Unit 12: Drawing and Mouse Events

AP CS Unit 12: Drawing and Mouse Events AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.

More information

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 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 information

Topic 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!

Topic 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 information

Dr. Hikmat A. M. AbdelJaber

Dr. Hikmat A. M. AbdelJaber Dr. Hikmat A. M. AbdelJaber Portion of the Java class hierarchy that include basic graphics classes and Java 2D API classes and interfaces. java.lang.object Java.awt.Color Java.awt.Component Java.awt.Container

More information

2IS45 Programming

2IS45 Programming Course Website Assignment Goals 2IS45 Programming http://www.win.tue.nl/~wsinswan/programmeren_2is45/ Rectangles Learn to use existing Abstract Data Types based on their contract (class Rectangle in Rectangle.

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors 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 CMPE212, FALL TERM, 2012 FINAL EXAMINATION 18 December 2012, 2pm Instructor: Alan McLeod If the instructor is unavailable

More information

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners GUI (Graphic User Interface) Programming Part 2 (Chapter 8) Chapter Goals To understand the Java event model To install action and mouse event listeners To accept input from buttons, text fields, and the

More information

FirstSwingFrame.java Page 1 of 1

FirstSwingFrame.java Page 1 of 1 FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import

More information

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) Layout Managment 1 Hello World Often have a run method to create and show a GUI Invoked by main calling invokelater private void run() { } JFrame frame = new JFrame("HelloWorldSwing");

More information

CompSci 230 S Programming Techniques. Basic GUI Components

CompSci 230 S Programming Techniques. Basic GUI Components CompSci 230 S1 2017 Programming Techniques Basic GUI Components Agenda Agenda Basic GUI Programming Concepts Graphical User Interface (GUI) Simple GUI-based Input/Output JFrame, JPanel & JLabel Using Layout

More information

Section Basic graphics

Section Basic graphics Chapter 16 - GUI Section 16.1 - Basic graphics Java supports a set of objects for developing graphical applications. A graphical application is a program that displays drawings and other graphical objects.

More information

User interfaces and Swing

User interfaces and Swing User interfaces and Swing Overview, applets, drawing, action listening, layout managers. APIs: java.awt.*, javax.swing.*, classes names start with a J. Java Lectures 1 2 Applets public class Simple extends

More information

Object-oriented programming in Java (2)

Object-oriented programming in Java (2) Programming Languages Week 13 Object-oriented programming in Java (2) College of Information Science and Engineering Ritsumeikan University plan last week intro to Java advantages and disadvantages language

More information

Programmierpraktikum

Programmierpraktikum Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 25 17/01/13 11:45 Swing Graphical User Interface (GUI) 2 of 25 17/01/13 11:45 Graphical

More information

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 :) )

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 :) ) 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 information

Final Examination Semester 3 / Year 2008

Final Examination Semester 3 / Year 2008 Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2008 COURSE : COMPUTER ORGANIZATION & OPERATING SYSTEM COURSE CODE : CSIS2053 CLASS : CS06-C, CS07-B,CS07-C TIME : 2 ½ HOURS DEPARTMENT

More information

CS 251 Intermediate Programming GUIs: Components and Layout

CS 251 Intermediate Programming GUIs: Components and Layout CS 251 Intermediate Programming GUIs: Components and Layout Brooke Chenoweth University of New Mexico Fall 2017 import javax. swing.*; Hello GUI public class HelloGUI extends JFrame { public HelloGUI ()

More information

Final Examination Semester 2 / Year 2012

Final Examination Semester 2 / Year 2012 Final Examination Semester 2 / Year 2012 COURSE : FUNDAMENTALS OF SOFTWARE DESIGEN AND DEVELOPMENT COURSE CODE : PROG1003 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : SO YONG QUAY Student

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors 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, 2012 FINAL EXAMINATION 9am to 12pm, 26 APRIL 2012 Instructor: Alan McLeod If the instructor is

More information

CSE wi Final Exam 3/12/18. Name UW ID#

CSE wi Final Exam 3/12/18. Name UW ID# Name UW ID# There are 13 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,

More information

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms. Java GUI Windows Events Drawing 1 Java GUI Toolkits Toolkit AWT Description Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

More information

Midterm Test II Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours. Answer all questions

Midterm Test II Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours. Answer all questions Midterm Test II 60-212 Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours Answer all questions Name : Student Id # : Only an unmarked copy of a textbook

More information

CS 11 java track: lecture 3

CS 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 information

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Overview Command line versus GUI apps

More information

CP122 Computer Science I. Chapter 2: Using Objects

CP122 Computer Science I. Chapter 2: Using Objects CP122 Computer Science I Chapter 2: Using Objects Tech News! Cyber Monday: $3.3B https://youtu.be/r4rfcay9fiq Tech News! Cyber Monday: $3.3B https://youtu.be/r4rfcay9fiq Small drone warfare https://cdn1.tnwcdn.com/wpcontent/blogs.dir/1/files/2016/11/ezgif.comoptimize-1-1.mp4

More information

Graphics 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) 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 information

Java Just in Time: Collected concepts after chapter 18

Java 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 information

Lecture 5: Java Graphics

Lecture 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 information

CS 180 Fall 2006 Exam II

CS 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 information

Reviewing OO Concepts

Reviewing OO Concepts Reviewing OO Concepts Users want to draw circles onto the display canvas. public class Circle { // more code here SWEN-261 Introduc2on to So3ware Engineering Department of So3ware Engineering Rochester

More information

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Graphics. Lecture 18 COP 3252 Summer June 6, 2017 Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple

More information

This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.

This 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 information

Unit 7: Event driven programming

Unit 7: Event driven programming Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 7: Event driven programming 1 1. Introduction 2.

More information

import javax.swing.*; import java.awt.*; import java.awt.event.*;

import javax.swing.*; import java.awt.*; import java.awt.event.*; I need to be walked through with why the stocks are being recognized "half way." They will print out in the console but won't be recognized by certain code. Every line of code seems to look right and that's

More information

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing CSEN401 Computer Programming Lab Topics: Graphical User Interface Window Interfaces using Swing Prof. Dr. Slim Abdennadher 22.3.2015 c S. Abdennadher 1 Swing c S. Abdennadher 2 AWT versus Swing Two basic

More information

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

I 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 information

Welcome 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 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 information

Lecture 3: Java Graphics & Events

Lecture 3: Java Graphics & Events Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new

More information

To gain experience using GUI components and listeners.

To 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 information

G51PRG: Introduction to Programming Second semester Applets and graphics

G51PRG: Introduction to Programming Second semester Applets and graphics G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting

More information

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1 Datenbank-Praktikum Universität zu Lübeck Sommersemester 2006 Lecture: Swing Ho Ngoc Duc 1 Learning objectives GUI applications Font, Color, Image Running Applets as applications Swing Components q q Text

More information

CIS 162 Project 1 Business Card Section 04 (Kurmas)

CIS 162 Project 1 Business Card Section 04 (Kurmas) CIS 162 Project 1 Business Card Section 04 (Kurmas) Due Date at the start of lab on Monday, 17 September (be prepared to demo in lab) Before Starting the Project Read zybook chapter 1 and 3 Know how to

More information

Lecture 18 Java Graphics and GUIs

Lecture 18 Java Graphics and GUIs CSE 331 Software Design and Implementation The plan Today: introduction to Java graphics and Swing/AWT libraries Then: event-driven programming and user interaction Lecture 18 Java Graphics and GUIs None

More information