An applet is called from within an HTML script with the APPLET tag, such as: <applet code="test.class" width=200 height=300></applet>
|
|
- Samuel Moore
- 5 years ago
- Views:
Transcription
1 6 Java Applets 6.1 Introduction As has been previously discussed a Java program can either be run as an applet within a WWW browser (such as Microsoft Internet Explorer or Netscape Communicator) or can be interpreted as a standalone program. The basic code within each program is almost the same and they can be easily converted from one to the other (typically a Java program will be run through an interpreter to test its results and then converted to run as an applet). 6.2 Applet tag An applet is called from within an HTML script with the APPLET tag, such as: <applet code="test.class" width=200 height=300></applet> which loads an applet called Test.class and sets the applet size to 200 pixels wide and 300 pixels high. Table 6.1 discusses some optional parameters. Table 6.1 Other applet HTML parameters Applet parameters CODEBASE=codebaseURL CODE=appletFile ALT=alternateText NAME=appletInstanceName Description Specifies the directory (codebaseurl) that contains the applet s code. Specifies the name of the file (appletfile) of the compiled applet. Specifies the alternative text that is displayed if the browser cannot run the Java applet. Specifies a name for the applet instance (appletinstancename). This makes it possible for applets on the same page to find each other. 67
2 Table 6.1 Other applet HTML parameters (cont.) Applet parameters WIDTH=pixels HEIGHT=pixels ALIGN=alignment VSPACE=pixels HSPACE=pixels Description Specifies the initial width and height (in pixels) of the applet. Specifies the alignment of the applet. Possible values are: left, right, top, texttop, middle, absmiddle, baseline, bottom and absbottom. Specifies the number of pixels above and below the applet (VSPACE) and on each side of the applet (HSPACE) Applet viewer A useful part of the JDK tools is an applet viewer which is used to test applets before they are run within the browser. The applet viewer on the PC version is AppletViewer.exe and the supplied argument is the HTML file that contains the applet tag(s). It then runs all the associated applets in separate windows. 6.3 Creating an applet Java applet 6.1 shows a simple Java applet which displays two lines of text and HTML script 6.1 shows how the applet integrates into an HTML script. First the Java applet (j1.java) is created. In this case the edit program is used. The directory listing below shows that the files created are chap6_01. java and chap6_01.html (note that Windows NT/95 displays the 8.3 filename format on the left-hand side of the directory listing and the long filename on the right-hand side). Java applet 6.1 (chap6_01.java) import java.awt.*; import java.applet.*; public class chap6_01 extends Applet g.drawstring("this is my first Java",5,25); g.drawstring("applet...",5,45); HTML script 6.1 (chap6_01.html) <HTML><TITLE>First Applet</TITLE> <APPLET CODE=chap6_01.class WIDTH=200 HEIGHT=200></APPLET></HTML> 68 Mastering Java
3 Sample run 6.1 C:\java\src\chap6> edit chap6_01.java C:\java\src\chap6> edit chap6_01.html C:\java\src\chap6> dir CHAP6_~1 HTM /05/98 18:40 chap6_01.html CHAP6_~1 JAV /05/98 22:35 chap6_01.java Next the Java applet is compiled using the javac.exe program. It can be seen from the listing that, if there are no errors, the compiled file is named chap6_01.class. This can then be used, with the HTML file, to run as an applet. Sample run 6.2 C:\java\src\chap6> javac chap6_01.java C:\java\src\chap6> dir CHAP6_~1 HTM /05/98 18:40 chap6_01.html CHAP6_~1 JAV /05/98 18:43 chap6_01.java CHAP6_~1 CLA /05/98 18:43 chap6_01.class C:\java\src\chap6> appletviewer chap6_01.html 6.4 Applet basics Java applet 6.1 recaps the previous Java applet. This section analyses the main parts of this Java applet. Java applet 6.1 (chap6_01.java) import java.awt.*; import java.applet.*; public class chap6_01 extends Applet g.drawstring("this is my first Java",5,25); g.drawstring("applet...",5,45); Applet class The start of the applet code is defined in the form: public class chap6_01 extends Applet which informs the Java compiler to create an applet named chap6_01 that extends the existing Applet class. The public keyword at the start of the statement allows the Java browser to run the applet, while if it is omitted the browser cannot access the applet. Java applets 69
4 The class keyword is used to creating a class object named chap6_01 that extends the applet class. After this the applet is defined between the left and right braces (grouping symbols) Applet methods Methods allow Java applets to be split into smaller sub-tasks (just as C uses functions). These methods have the advantage that: They allow code to be reused. They allow for top-level design. They make applet debugging easier as each method can be tested in isolation to the rest of the applet. A method has the public keyword, followed by the return value (if any) and the name of the method. After this the parameters passed to the method are defined within rounded brackets. Recapping from the previous example: g.drawstring("this is my first Java",5,25); g.drawstring("applet...",5,45); This method has the public keyword which allows any user to execute the method. The void type defines that there is nothing returned from this method and the name of the method is paint(). The parameter passed into the method is g which has the data type of Graphics. Within the paint() method the drawstring() method is called. This method is defined in java. awt.graphics class library (this library has been included with the import java.awt.* statement. The definition for this method is: public abstract void drawstring(string str, int x, int y) which draws a string of characters using the current font and colour. The x,y position is the starting point of the baseline of the string (str). It should be noted that Java is case sensitive and the names given must be referred to in the case that they are defined as. 6.5 The paint() object The paint() object is the object that is called whenever the applet is redrawn. It will thus be called whenever the applet is run and then it is called whenever the applet is redisplayed. 70 Mastering Java
5 Java applet 6.2 shows how a for() loop can be used to display the square and cube of the values from 0 to 9. Notice that the final value of i within the for() loop is 9 because the end condition is i<10 (while i is less than 10). Java applet 6.2 (chap6_02.java) import java.awt.*; import java.applet.*; public class chap6_02 extends Applet int i; g.drawstring("value Square Cube",5,10); for (i=0;i<10;i++) g.drawstring(""+ i,5,20+10*i); g.drawstring(""+ i*i,45,20+10*i); g.drawstring(""+ i*i*i,85,20+10*i); HTML script 6.2 (chap6_02.html) <HTML> <TITLE>First Applet</TITLE> <APPLET CODE=chap6_02.class WIDTH=200 HEIGHT=200></APPLET></HTML> Java applet 6.3 uses a for() loop and the if() statement to test if a value is less than, equal to or greater than 5. The loop is used to repeat the test 10 times. Java applet 6.3 (chap6_03.java) import java.awt.*; import java.applet.*; import java.lang.math; public class chap6_03 extends Applet int i,x; double val; for (i=0;i<10;i++) val=math.random(); x=(int)(val*10.0); // Convert value between 0 and 10 if (x<5) g.drawstring("less than 5",5,20+i*10); else if (x==5) g.drawstring("equal to 5",5,20+i*10); else g.drawstring("greater than 5",5,20+i*10); Java applets 71
6 HTML script 6.3 (chap6_03.html) <HTML> <TITLE>First Applet</TITLE> <APPLET CODE=chap6_03.class WIDTH=200 HEIGHT=200> </APPLET></HTML> The random() method is used to generate a value between 0 and 1, the returned value is then multiplied by 10 so as to convert into a value between 0 and 10. Then it is converted to an integer using the data type modifier (int). The if() statement is then used to test the value. 6.6 Exercises Write a Java applet which displays the following table of powers. Value Square Cube Fourth power Write a Java applet which displays the following table of square root values from 1 to 15. Value Square root Write a Java applet which display 20 random numbers from between 0 and Mastering Java
7 6.6.4 Convert the following exercises so that they run within an applet: (i) Exercise (ii) Exercise (iii) Exercise (iv) Project at the end of Chapter 5. (v) Exercise Write a Java applet that simulates the rolling of two dice. A sample output is: Dice 1: 3 Dice 2: 5 Total: Using a Java applet determine the results of the following: (i) (ii) tan 1 ( 0.5) (iii) sin( 2.1) (iv) (v) (vi) e 2.5 (Hint: use atan()) 6.7 Project Write a Java applet which contains all the cards in a deck. It will then give the deck a shuffle and display the cards in the deck. Java program 6.4 shows an outline of a program but does not contain all of the cards in the deck. Sample run 6.3 shows a sample run of the program. Implement the following: (i) Convert the program to an applet. (ii) Add the rest of the card to the deck. (iii) Increase the number of shuffles. (iv) Add suits to the deck. Java program 6.4 (chap6_04.java) import java.lang.math; public class chap6_04 Java applets 73
8 public static void main(string[] args) String names[]="ace","king", "Queen","Jack", "10"; Cards card = new Cards(); card.name=names; card.nshuffle=20; // 20 shuffles of cards System.out.println("Before shuffle"); card.show(); card.shuffle(); System.out.println("After shuffle"); card.show(); class Cards String name[]; int nshuffle; public void show() int i; for (i=0;i<name.length;i++) System.out.println(name[i]); public void shuffle() int i, pos1, pos2; String tempstr; for (i=0;i<nshuffle;i++) pos1=(int) ((name.length)*math.random()); pos2=(int) ((name.length)*math.random()); tempstr=name[pos1]; name[pos1]=name[pos2]; name[pos2]=tempstr; Sample run 6.3 Before shuffle Ace King Queen Jack 10 After shuffle King 10 Jack Queen Ace 74 Mastering Java
SIMPLE APPLET PROGRAM
APPLETS Applets are small applications that are accessed on Internet Server, transported over Internet, automatically installed and run as a part of web- browser Applet Basics : - All applets are subclasses
More informationIntroduction to Java Applets 12
Introduction to Java Applets 12 Course Map This module discusses the support for applets by the JDK, and how applets differ from applications in terms of program form, operating context, and how they are
More informationModule 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet
About Applets Module 5 Applets An applet is a little application. Prior to the World Wide Web, the built-in writing and drawing programs that came with Windows were sometimes called "applets." On the Web,
More informationPrashanth Kumar K(Head-Dept of Computers)
B.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Unit-IV 1 1. What is Thread? Thread is a task or flow of execution that can be made to run using time-sharing principle.
More informationPROGRAMMING LANGUAGE 2
1 PROGRAMMING LANGUAGE 2 Lecture 13. Java Applets Outline 2 Applet Fundamentals Applet class Applet Fundamentals 3 Applets are small applications that are accessed on an Internet server, transported over
More informationOBJECT ORIENTED PROGRAMMING. Course 8 Loredana STANCIU Room B613
OBJECT ORIENTED PROGRAMMING Course 8 Loredana STANCIU loredana.stanciu@upt.ro Room B613 Applets A program written in the Java programming language that can be included in an HTML page A special kind of
More informationINTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 9: Writing Java Applets. Introduction
INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 9: Writing Java Applets Introduction Applets are Java programs that execute within HTML pages. There are three stages to creating a working Java
More informationRoad Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets
Java Applets Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets Introduce inheritance Introduce the applet environment html needed for applets Reading:
More informationModule 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani The HTML APPLET Tag An applet viewer will execute each APPLET tag that it finds in a separate window, while web browsers
More informationUnit 1- Java Applets. Applet Programming. Local Applet and Remote Applet ** Applet and Application
Applet Programming Applets are small Java applications that can be accessed on an Internet server, transported over Internet, and can be automatically installed and run as a part of a web document. An
More informationModule 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani The Applet Class Types of Applets (Abstract Window Toolkit) Offers richer and easy to use interface than AWT. An Applet
More informationModule 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2017-18 Prof. Mouna M. Naravani The Applet Class Types of Applets (Abstract Window Toolkit) Offers richer and easy to use interface than AWT. An Applet
More informationAdvanced Internet Programming CSY3020
Advanced Internet Programming CSY3020 Java Applets The three Java Applet examples produce a very rudimentary drawing applet. An Applet is compiled Java which is normally run within a browser. Java applets
More informationUNIT-2: CLASSES, INHERITANCE, EXCEPTIONS, APPLETS. To define a class, use the class keyword and the name of the class:
UNIT-2: CLASSES, INHERITANCE, EXCEPTIONS, APPLETS 1. Defining Classes, Class Name To define a class, use the class keyword and the name of the class: class MyClassName {... If this class is a subclass
More informationGoals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java
Goals Understand the basics of Java. Introduction to Java Write simple Java Programs. 1 2 Java - An Introduction Java is Compiled and Interpreted Java - The programming language from Sun Microsystems Programmer
More informationContents 8-1. Copyright (c) N. Afshartous
Contents 1. Classes and Objects 2. Inheritance 3. Interfaces 4. Exceptions and Error Handling 5. Intro to Concurrency 6. Concurrency in Java 7. Graphics and Animation 8. Applets 8-1 Chapter 8: Applets
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 informationAn applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a
CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled
More information9. APPLETS AND APPLICATIONS
9. APPLETS AND APPLICATIONS JAVA PROGRAMMING(2350703) The Applet class What is an Applet? An applet is a Java program that embedded with web content(html) and runs in a Web browser. It runs inside the
More informationChapter 3 - Introduction to Java Applets
1 Chapter 3 - Introduction to Java Applets 2 Introduction Applet Program that runs in appletviewer (test utility for applets) Web browser (IE, Communicator) Executes when HTML (Hypertext Markup Language)
More informationJava Applet Basics. Life cycle of an applet:
Java Applet Basics Applet is a Java program that can be embedded into a web page. It runs inside the web browser and works at client side. Applet is embedded in a HTML page using the APPLET or OBJECT tag
More informationJava Applet & its life Cycle. By Iqtidar Ali
Java Applet & its life Cycle By Iqtidar Ali Java Applet Basic An applet is a java program that runs in a Web browser. An applet can be said as a fully functional java application. When browsing the Web,
More informationCSC System Development with Java Introduction to Java Applets Budditha Hettige
CSC 308 2.0 System Development with Java Introduction to Java Applets Budditha Hettige Department of Statistics and Computer Science What is an applet? applet: a Java program that can be inserted into
More informationCS335 Graphics and Multimedia
CS335 Graphics and Multimedia Fuhua (Frank) Cheng Department of Computer Science University of Kentucky Lexington, KY 40506-0046 -2-1. Programming Using JAVA JAVA history: WHY JAVA? Simple Objected-oriented
More informationProgramming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 06 Demonstration II So, in the last lecture, we have learned
More informationObject Oriented Programming Concepts-15CS45
Module 05 Chethan Raj C Assistant Professor Dept. of CSE APPLET: 1. Introduction 2. Two types of Applets 3. Applet basics 4. Applet Architecture 5. An Applet skeleton 6. Simple Applet display methods 7.
More informationUNIT -1 JAVA APPLETS
UNIT -1 JAVA APPLETS TOPICS TO BE COVERED 1.1 Concept of Applet Programming Local and Remote applets Difference between applet and application Preparing to write applets Building applet code Applet life
More informationMethods (Deitel chapter 6)
Methods (Deitel chapter 6) 1 Plan 2 Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods
More informationJava TM Applets. Rex Jaeschke
Java TM Applets Rex Jaeschke Java Applets 1997 1998, 2009 Rex Jaeschke. All rights reserved. Edition: 3.0 (matches JDK1.6/Java 2) All rights reserved. No part of this publication may be reproduced, stored
More informationCORBA Java. Java. Java. . Java CORBA. Java CORBA (RMI) CORBA ORB. . CORBA. CORBA Java
CORBA Java?? OMG CORBA IDL C, C++, SmallTalk, Ada Java COBOL, ORB C Ada Java C++ CORBA Java CORBA Java (RMI) JDK12 Java CORBA ORB CORBA,, CORBA? CORBA,,, CORBA, CORBA CORBA Java (, ) Java CORBA Java :
More informationG51PRG: 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 informationArrays. Comp Sci 1570 Introduction to C++ Array basics. arrays. Arrays as parameters to functions. Sorting arrays. Random stuff
and Arrays Comp Sci 1570 Introduction to C++ Outline and 1 2 Multi-dimensional and 3 4 5 Outline and 1 2 Multi-dimensional and 3 4 5 Array declaration and An array is a series of elements of the same type
More informationMethods (Deitel chapter 6)
1 Plan 2 Methods (Deitel chapter ) Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods
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 informationCS 209 Programming in Java #12 JAR Files: Creation and Use
CS 209 Programming in Java #12 JAR Files: Creation and Use Textbook Chapter 14 Spring, 2006 Instructor: J.G. Neal 1 Topics Introduction to JAR Files Using the JAR Tool for an Applet Deploying an Applet
More informationGETTING STARTED. The longest journey begins with a single step. In this chapter, you will learn about: Compiling and Running a Java Program Page 2
ch01 11/17/99 9:16 AM Page 1 CHAPTER 1 GETTING STARTED The longest journey begins with a single step. CHAPTER OBJECTIVES In this chapter, you will learn about: Compiling and Running a Java Program Page
More informationUnderstanding How Java Programs Work
HOUR 4 Understanding How Java Programs Work An important distinction to make in Java programming is where your program is supposed to be running. Some programs are intended to work on your computer; you
More informationGraphics Applets. By Mr. Dave Clausen
Graphics Applets By Mr. Dave Clausen Applets A Java application is a stand-alone program with a main method (like the ones we've seen so far) A Java applet is a program that is intended to transported
More informationChapter 7 Applets. Answers
Chapter 7 Applets Answers 1. D The drawoval(x, y, width, height) method of graphics draws an empty oval within a bounding box, and accepts 4 int parameters. The x and y coordinates of the left/top point
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More informationHigher National Diploma in Information Technology First Year, Second Semester Examination 2015
[All Rights Reserved] SLIATE SRI LANKA INSTITUTE OF ADVANCED TECHNOLOGICAL EDUCATION (Established in the Ministry of Higher Education, vide in Act No. 29 of 1995) Higher National Diploma in Information
More informationLecture Static Methods and Variables. Static Methods
Lecture 15.1 Static Methods and Variables Static Methods In Java it is possible to declare methods and variables to belong to a class rather than an object. This is done by declaring them to be static.
More informationPrograms, Statements, Variables
Programs, Statements, Variables Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria Wolfgang.Schreiner@risc.jku.at http://www.risc.jku.at Wolfgang
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 informationPointers and scanf() Steven R. Bagley
Pointers and scanf() Steven R. Bagley Recap Programs are a series of statements Defined in functions Can call functions to alter program flow if statement can determine whether code gets run Loops can
More informationCSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University
Graphics & Applets CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Back to Chapter
More information1. What is Jav a? simple
1. What is Jav a? Thanks to Java is a new programming language developed at Sun under the direction of James Gosling. As far as possible it is based on concepts from C, Objective C and C++. Java is interpreted
More informationCHAPTER 7 WEB SERVERS AND WEB BROWSERS
CHAPTER 7 WEB SERVERS AND WEB BROWSERS Browser INTRODUCTION A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information
More informationChapter 13. Applets and HTML. HTML Applets. Chapter 13 Java: an Introduction to Computer Science & Programming - Walter Savitch 1
Chapter 13 Applets and HTML HTML Applets Chapter 13 Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Overview Applets: Java programs designed to run from a document on the Internet
More informationIntroduction to Computer Science I
Introduction to Computer Science I Graphics Janyl Jumadinova 7 February, 2018 Graphics Graphics can be simple or complex, but they are just data like a text document or sound. Java is pretty good at graphics,
More informationMany folks new to Java find the distinctions between applets and applications
2 APPLETS AND APPLICATIONS KEITH RUTLEDGE Many folks new to Java find the distinctions between applets and applications unsettling and more than a little confusing. I have even had programmers learning
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationOBJECT ORIENTED PROGRAMMING TYm. Allotted : 3 Hours Full Marks: 70
I,.. CI/. T.cH/C8E/ODD SEM/SEM-5/CS-504D/2016-17... AiIIIII "-AmI u...iir e~ IlAULAKA ABUL KALAM AZAD UNIVERSITY TECHNOLOGY,~TBENGAL Paper Code: CS-504D OF OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3
More informationASSIGNMENT NO 14. Objectives: To learn and demonstrated use of applet and swing components
Create an applet with three text Fields and four buttons add, subtract, multiply and divide. User will enter two values in the Text Fields. When any button is pressed, the corresponding operation is performed
More information7 Control Structures, Logical Statements
7 Control Structures, Logical Statements 7.1 Logical Statements 1. Logical (true or false) statements comparing scalars or matrices can be evaluated in MATLAB. Two matrices of the same size may be compared,
More information1 Short Answer (5 Points Each)
COSC 117 Exam #1 Solutions Fall 015 1 Short Answer (5 Points Each) 1. What is the difference between a compiler and an interpreter? Also, discuss Java s method. A compiler will take a program written in
More informationChapter 27. HTTP and WWW
Chapter 27 HTTP and WWW 27.1 HTTP Transaction Request Message Response Message Headers Note: HTTP uses the services of TCP on well-known port 80. Figure 27.1 HTTP transaction Figure 27.2 Request message
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 informationAgenda. Announcements. Extreme Java G Session 2 - Main Theme Java Tools and Software Engineering Techniques
Extreme Java G22.3033-007 Session 2 - Main Theme Java Tools and Software Engineering Techniques Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical
More informationLecture 5: Methods CS2301
Lecture 5: Methods NADA ALZAHRANI CS2301 1 Opening Problem Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively. 2 Solution public static int sum(int i1, int i2) { int
More informationMidterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.
Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Name: ID: Problem 1) (8 points) For the following code segment, what are the values of i, j, k, and d, after the segment
More informationCOMP 110 Programming Exercise: Simulation of the Game of Craps
COMP 110 Programming Exercise: Simulation of the Game of Craps Craps is a game of chance played by rolling two dice for a series of rolls and placing bets on the outcomes. The background on probability,
More informationSoftware Concepts. 2-8 Explain the process of translating and executing a Java program. How might the World Wide Web be involved?
CHAPTER 2 Software Concepts Notes This chapter explores how programs are written and the process of compiling a program into machine language. Basic programs are presented and discussed. High-level software
More informationEE219 - Semester /2009 Solutions Page 1 of 10
EE219 Object Oriented Programming I (2008/2009) SEMESTER 1 SOLUTIONS Q1(a) Corrected code is: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
More informationS.E (Computer ) (Second Semester) EXAMINATION, Time : Two Hours Maximum Marks : 50
S.E (Computer ) (Second Semester) EXAMINATION, 2017 PRINCIPLES OF PROGRAMMING LANGUAGE (2015 PATTERN) Time : Two Hours Maximum Marks : 50 N.B. :- (i) All questions are compulsory (ii)neat diagrams must
More informationChapter 5 - Methods Prentice Hall, Inc. All rights reserved.
1 Chapter 5 - Methods 2003 Prentice Hall, Inc. All rights reserved. 2 Introduction Modules Small pieces of a problem e.g., divide and conquer Facilitate design, implementation, operation and maintenance
More informationS.E. Sem. III [CMPN] Object Oriented Programming Methodology
S.E. Sem. III [CMPN] Object Oriented Programming Methodology Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 80 Q.1(a) Write a program to calculate GCD of two numbers in java. [5] (A) import java.util.*;
More informationIntroduction to the Java T M Language
Introduction to the Java T M Language Jan H. Meinke July 1, 2000 1 Introduction Since its introduction in 1995 Java has become one of the most popular programming language. At first powered by the popularity
More informationLab 3: Work with data (IV)
CS2370.03 Java Programming Spring 2005 Dr. Zhizhang Shen Background Lab 3: Work with data (IV) In this lab, we will go through a series of exercises to learn some basics of working with data, including
More informationJava Programming Language Mr.Rungrote Phonkam
2 Java Programming Language Mr.Rungrote Phonkam rungrote@it.kmitl.ac.th Contents 1. Intro to Java. 2. Java Platform 3. Java Language 4. JDK 5. Programming Steps 6. Visual Programming 7. Basic Programming
More informationTHE CATHOLIC UNIVERSITY OF EASTERN AFRICA A. M. E. C. E. A
THE CATHOLIC UNIVERSITY OF EASTERN AFRICA A. M. E. C. E. A MAIN EXAMINATION P.O. Box 62157 00200 Nairobi - KENYA Telephone: 891601-6 Fax: 254-20-891084 E-mail:academics@cuea.edu AUGUST - DECEMBER 2015
More informationTWO-DIMENSIONAL FIGURES
TWO-DIMENSIONAL FIGURES Two-dimensional (D) figures can be rendered by a graphics context. Here are the Graphics methods for drawing draw common figures: java.awt.graphics Methods to Draw Lines, Rectangles
More informationGraphics Applets. By Mr. Dave Clausen
Graphics Applets By Mr. Dave Clausen Applets A Java application is a stand-alone program with a main method (like the ones we've seen so far) A Java applet is a program that is intended to transported
More informationArray Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7)
Array Basics: Outline Arrays (Savitch, Chapter 7) TOPICS Array Basics Arrays in Classes and Methods Programming with Arrays Searching and Sorting Arrays Multi-Dimensional Arrays Static Variables and Constants
More informationEE219 Object Oriented Programming I (2005/2006) SEMESTER 1 SOLUTIONS
Q1(a) Corrected code is: EE219 Object Oriented Programming I (2005/2006) SEMESTER 1 SOLUTIONS 01 #include 02 using namespace std; 03 04 class Question1 05 06 int a,b,*p; 07 08 public: 09 Question1(int
More informationMODULE 8p - Applets - Trials B
MODULE 8p - Applets - Trials B The applet to be developed in this series of trials is called AppletB. The first version is a simple modification of AppletA but should be saved in AppletB.java import java.applet.applet;
More informationYou should now start on Chapter 4. Chapter 4 introduces the following concepts
Summary By this stage, you have met the following principles : the relationship between classes and objects that a class represents our understanding of something weʼre interested in, in a special and
More informationReview Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous
Assignment 3 Methods Review CSC 123 Fall 2018 Notes: All homework must be submitted via e-mail. All parts of assignment must be submitted in a single e-mail with multiple attachments when required. Notes:
More informationSummary. 962 Chapter 23 Applets and Java Web Start
962 Chapter 23 Applets and Java Web Start Summary Section 23.1 Introduction Applets (p. 942) are Java programs that are typically embedded in HTML (Extensible Hyper- Text Markup Language) documents also
More informationCSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name:
CSC 1051 Algorithms and Data Structures I Midterm Examination March 2, 2017 Name: Question Value Score 1 10 2 10 3 20 4 20 5 20 6 20 TOTAL 100 Please answer questions in the spaces provided. If you make
More informationCS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:
CS1046 Lab 4 Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to: Define the terms: function, calling and user-defined function and predefined function
More informationLecture Static Methods and Variables. Static Methods
Lecture 15.1 Static Methods and Variables Static Methods In Java it is possible to declare methods and variables to belong to a class rather than an object. This is done by declaring them to be static.
More informationLecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8
Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How
More informationChapter Two Bonus Lesson: JavaDoc
We ve already talked about adding simple comments to your source code. The JDK actually supports more meaningful comments as well. If you add specially-formatted comments, you can then use a tool called
More informationIntroduction. Overview of the Course on Java. Overview of Part 1 of the Course
Introduction Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu /~spring Overview of the Course on Java Part
More informationINFS 2150 / 7150 Intro to Web Development / HTML Programming
XP INFS 2150 / 7150 Intro to Web Development / HTML Programming Working with Graphics in a Web Page 1 Objectives Learn about different image formats Control the placement and appearance of images on a
More informationFacebook Google plus Twitter
LEARNING STARTS WITH VIEWING THE WORLD DIFFERENTLY. Knowledge flow- A mobile learning platform provides apps, ebooks and video tutorials Knowledge flow brings you learning ebook of Java for Beginners.
More information1 Getting started with Processing
cisc3665, fall 2011, lab I.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For
More informationUsing Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics
Using Methods Methods that handle events Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Caveat The term function is used in Processing e.g. line(),
More informationMethods. Eng. Mohammed Abdualal
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 8 Methods
More informationLEARNING STARTS WITH VIEWING THE WORLD DIFFERENTLY. Knowledge flow- A mobile learning platform provides
LEARNING STARTS WITH VIEWING THE WORLD DIFFERENTLY. Knowledge flow- A mobile learning platform provides apps, ebooks and video tutorials Knowledge flow brings you learning ebook of Java for Beginners.
More informationJava Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology
Java Applets, etc. Instructor: Dmitri A. Gusev Fall 2007 CS 502: Computers and Communications Technology Lecture 25, December 5, 2007 CGI (Common Gateway Interface) CGI is a standard for handling forms'
More informationChapter 3 - Functions
Chapter 3 - Functions 1 Outline 3.1 Introduction 3.2 Program Components in C++ 3.3 Math Library Functions 3.4 Functions 3.5 Function Definitions 3.6 Function Prototypes 3.7 Header Files 3.8 Random Number
More informationAdvance Programming. BCA Fifth Semester. Purbanchal University. sarojpandey.com.np Page 1 of 101
Advance Programming In Java Purbanchal University BCA Fifth Semester sarojpandey.com.np Page 1 of 101 Java Basics 1. Overview of Object- Oriented Programming 1.1. Objects and Classes 1.2. Data Abstraction
More informationOutline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform
Outline Introduction to Java Introduction Java 2 Platform CS 3300 Object-Oriented Concepts Introduction to Java 2 What Is Java? History Characteristics of Java History James Gosling at Sun Microsystems
More informationSoftware and Programming 1
Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 17 January 2019 SP1-Lab1-2018-19.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon
More informationChapter 1 Introduction to Java
Chapter 1 Introduction to Java Lesson page 0-1. Introduction to Livetexts Question 1. A livetext is a text that relies not only on the printed word but also on graphics, animation, audio, the computer,
More informationUsing the API: Introductory Graphics Java Programming 1 Lesson 8
Using the API: Introductory Graphics Java Programming 1 Lesson 8 Using Java Provided Classes In this lesson we'll focus on using the Graphics class and its capabilities. This will serve two purposes: first
More information12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started
More informationChapter 1 Introduction to Computers, Programs, and Java
Chapter 1 Introduction to Computers, Programs, and Java 1 Programs Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs. Without programs,
More information