Course Intro Instructor Intro Java Intro, Continued
|
|
|
- Jeffry Carr
- 9 years ago
- Views:
Transcription
1 Course Intro Instructor Intro Java Intro, Continued
2 The syllabus Java etc. To submit your homework, do Team > Share Your repository name is csse username Use your old SVN password.
3 Note to assistants: If you notice someone using a laptop for noncourse stuff during class discussions, please give that person a gentle reminder. You will generally need to use your laptops during at least a portion of every class period. Please be sure to bring your laptop, a power brick, and a network cable to class. You, me, and YouTube Turn off IM and software and only use other software for things directly related to class If you choose to use non-class-related software or websites during class, you must sit in the next-to-last row.
4 Cell Phones please set ringers to silent or quiet. Minimize class disruptions. But sometimes there are emergencies. Personal needs If you need to leave class for a drink of water, a trip to the bathroom, or anything like that, you need not ask me. Just try to minimize disruptions. Please be here and have your computer up and running by 8:05.
5 In the textbook In any of my materials. Use the Bug Report Forum on ANGEL More details in the Syllabus.
6 Plagiarism has sometimes been a problem in courses at this level. I won't look hard for it, but if I do happen to find it, watch out! Of course, copying from the work of previous terms' students is just as bad as copying from this term's students. If you use someone else's ideas, attribute them. If you use someone else's code, don't submit it!
7 See the syllabus Get help in ways that increase understanding Don t get or give help that bypasses learning. My usual penalty for plagiarism or cheating. If the assignment or exam is worth N points, your score will be N (not zero) Why? In cases of electronic copying (and perhaps other cases), the penalty may apply to both giver and receiver. If you are not sure whether a certain kind of collaboration is appropriate, ask me before you do it.
8 Reinforce and extend OO ideas from 120 Major emphasis on inheritance GUI programming using Java Swing Data Structures Introduce Algorithm efficiency analysis Abstract Data Types Specifying and using standard Data Structures Implementing simple data structures (lists) Recursion Simple Sorting and searching A few additional Software Engineering concepts
9 What will I spend my time doing? Larger programming problems, mostly outside of class. Exploring the JDK documentation to find the classes and methods that you need. Debugging! Reviewing other students code. Reading (a lot to read at the beginning; less later). Thinking about exercises in the textbooks. Some written exercises, mostly from the textbook. Small programming assignments in class (some to be continued for homework). Discussing the material with other students.
10 This course is about participating, doing. When we are having a class discussion, you may not always be the one to answer aloud, but try to THINK the answer before someone else verbalizes! Consider Mary and Bob: Mary is active and engaged Bob just sits there absorbing Outcomes?
11 Import the Scanner class from the java.util package. System.in is Java's standard input stream. Note that this means the variable called in in the System class. import java.math.biginteger; import java.util.scanner; public class Factorial_6_Scanner { public static final int MAX = 25; public static BigInteger factorial(int n) { BigInteger prod = BigInteger.ONE; for (int i=1; i<=n; i++) prod = prod.multiply(new BigInteger(i +"")); return prod; Other Scanner methods include nextdouble(), nextline(), nextboolean, hasnextint(). hasnextline(). public static void main(string[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter a nonnegative integer: "); int n = scanner.nextint(); System.out.println(n + "! = " + factorial(n) ); If we do not do the import, we can write java.util.scanner sc = new java.util.scanner(system.in); So import is a simple convenient shortcut
12 Using the new Scanner class is easier than this approach. But you will often see the old approach in other people's code (including Mark Weiss' code). Think of this as the "magic incantation" for getting set up to read from standard input. readline( ) returns the next line of input as a String. Since readline( ) could generate an IO Exception, the try/catch is required. import java.math.biginteger; import java.io.ioexception; import java.io.inputstreamreader; import java.io.bufferedreader; // omitted definition of the factorial method public static void main(string[] args) { BufferedReader in = new BufferedReader( new InputStreamReader(System.in)); String line = ""; System.out.print("Enter a positive integer: "); try { line = in.readline(); catch (IOException e) { System.out.println("Could not read input"); int n = Integer.parseInt(line); System.out.println(n + "! = " + factorial(n) ); parseint( ) takes a string that represents an integer and returns the corresponding int value. It is somewhat similar to Python's int( ) function.
13 If any exception gets thrown by the code in the try clause, the catch clauses are tested in order to find the first one that matches the actual exception type. If none match, the exception is thrown back to whatever method called this one. If it is never caught, the program crashes. import java.math.biginteger; public class Factorial_9_InputErrors { public static BigInteger factorial(int n) { if (n < 0) throw new IllegalArgumentException(); BigInteger prod = BigInteger.ONE; for (int i = 1; i <= n; i++) prod = prod.multiply(new BigInteger(i + "")); return prod; public static void main(string[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter a nonnegative integer: "); try { int n = scanner.nextint(); System.out.println(n + "! = " + factorial(n)); catch (InputMismatchException e) { System.out.println( Must be an integer"); catch (IllegalArgumentException e) { System.out.println( Cannot be negative");
14 Discuss with the person next to you (for two or three minutes): First, tell that person something she/he probably does not know about you. What does each of the following mean? What can you say about how it is used? try catch finally throw throws Run some code that might throw an exception if this type of exception is thrown, run the following code (i.e. handle the exception). Run this code at the end, whether there is an exception or not. I discovered something I don't know how to handle. Does anyone who called me know what to do? This method might throw this kind of checked exception. If it does, I'm not handling it! Documentation for the compiler and users!
15 import java.math.biginteger; Recursive factorial definition: n! = 1 if n = 0 n! = (n-1)! n if n>0 public class Factorial_10_Recursive { public static final int MAX = 30; /* Return the factorial of n */ public static BigInteger factorial(int n) { if (n < 0) throw new IllegalArgumentException(); if (n == 0) return BigInteger.ONE; return new BigInteger(n+ "").multiply(factorial(n-1)); public static void main(string[] args) { for (int i=0; i <= MAX; i++) System.out.println(i + "! = " + factorial(i) ); Recursive basically means: The method calls itself.
16 import java.math.biginteger; Store previously-computed values in an array called vals public class Factorial_11_Caching { public static final int MAX = 2000; static int count = 0; // How many values have we cached so far? static BigInteger[] vals = new BigInteger[MAX+1]; // the cache static { vals[0] = BigInteger.ONE; // Static initializer /* Return the factorial of n */ public static BigInteger factorial(int n) { if (n < 0 n > MAX) throw new IllegalArgumentException(); if (n <= count) // If we have already computed it return vals[n]; BigInteger val = new BigInteger(n+ "").multiply(factorial(n-1)); vals[n] = val; // Cache the computed value before returning it count = n; return val; // Code for main()omitted. Same as in previous example.
17
18 import java.util.*; import java.io.*; public class FileIOTest { /* Copy an input file to an output file, changing all letters to uppercase. This approach can be used for input processing in almost any program. */ public static void main(string[] args) { String inputfilename = "samplefile.txt"; String outputfilename = "uppercasedfile.txt"; try { Scanner sc = new Scanner(new File(inputFileName)); PrintWriter out = new PrintWriter(new File(outputFileName)); while (sc.hasnextline()){ // process one line String line = sc.nextline(); line = line.touppercase(); for (int i= 0; i< line.length(); i++) // normally we might do something with each character in the line. out.print(line.charat(i)); out.println(); out.close(); catch (IOException e) { e.printstacktrace();
19 import java.util.scanner; import java.io.*; public class TryFileInputOutput { public static void main(string[] args) { String infilename=null,outfilename = "outfile.txt"; Scanner filescanner; PrintWriter out; try { user enters the name Scanner sc = new Scanner(System.in); of an input file that while (true) // until we get a valid file. try { we can actually System.out.print("Enter input file name: "); open. infilename = sc.nextline(); filescanner = new Scanner(new File(inFileName)); break; // we have a valid file, so exit the loop. catch(filenotfoundexception e) { System.out.println("Did not find file " + infilename + ". Try again!"); out = new PrintWriter(new File (outfilename)); while (filescanner.hasnextline()){ // process one line String line = filescanner.nextline(); line = line.touppercase(); for (int i=0; i<line.length(); i++) out.print(line.charat(i)); // process each char on the line out.println(); out.close(); filescanner.close(); System.out.println("Done!"); catch (IOException e) { e.printstacktrace(); Essentially the same as before Keep looping until Essentially the same as before
20 1-29 Copyright 2006 Pearson Addison-Wesley. All rights reserved.
21 1-30 Copyright 2006 Pearson Addison-Wesley. All rights reserved.
22 // Adapted from Java Examples in a NutShell 3rd Ed, by David Flanagan. // The children's game FizzBuzz. public class FizzBuzz { public static void main(string[] args) { for(int i = 1; i <= 100; i++) { // count from 1 to 100 switch(i % 35) { // What's the remainder mod 35? case 0: // For multiples of System.out.print("fizzbuzz "); // print "fizzbuzz". break; // Don't forget this statement! case 5: case 10: case 15: // If the remainder is any of these case 20: case 25: case 30: // then the number is a multiple of 5 System.out.print("fizz "); // so print "fizz". break; case 7: case 14: case 21: case 28: // For any multiple of 7... System.out.print("buzz "); // print "buzz". break; default: // For any other number... System.out.print(i + " "); // print the number. break; if (i%10 == 0) System.out.println(); fizz 6 buzz 8 9 fizz buzz fizz fizz buzz fizz buzz 29 fizz fizzbuzz fizz 41 buzz fizz buzz fizz fizz buzz fizz buzz 64 fizz fizzbuzz fizz 76 buzz fizz buzz fizz fizz buzz fizz buzz 99 fizz
23 What do you think it is? Testing parts of your code in isolation before putting them all together Why is it a good thing? How do I write good test cases? Test all types of inputs, including boundary cases. Practice! How easy is it to do it in Eclipse? Fairly so, with JUnit I will often give you unit tests to help you write correct code. Here are some to test last night s homework Check out HW1Test from: hulman.edu/repos/csse username
24 Write appropriate comments: Javadoc comments for public fields and methods. Explanations of anything else that is not obvious. Give explanatory variable and method names: Use name completion in Eclipse, Alt-/ to keep typing cost low and readability high Use local variables and static methods (instead of fields and non-static methods) where appropriate. where appropriate includes any place where you can t explicitly justify doing otherwise. Use Ctrl-Shift-F in Eclipse to format your code.
25 Go there now
Chulalongkorn University International School of Engineering Department of Computer Engineering 2140105 Computer Programming Lab.
Chulalongkorn University Name International School of Engineering Student ID Department of Computer Engineering Station No. 2140105 Computer Programming Lab. Date Lab 2 Using Java API documents, command
File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)
File class in Java File Input and Output (Savitch, Chapter 10) TOPICS File Input Exception Handling File Output Programmers refer to input/output as "I/O". The File class represents files as objects. The
CS 121 Intro to Programming:Java - Lecture 11 Announcements
CS 121 Intro to Programming:Java - Lecture 11 Announcements Next Owl assignment up, due Friday (it s short!) Programming assignment due next Monday morning Preregistration advice: More computing? Take
Using Files as Input/Output in Java 5.0 Applications
Using Files as Input/Output in Java 5.0 Applications The goal of this module is to present enough information about files to allow you to write applications in Java that fetch their input from a file instead
CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O
CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O 1 Sending Output to a (Text) File import java.util.scanner; import java.io.*; public class TextFileOutputDemo1 public static void
Introduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
Creating a Simple, Multithreaded Chat System with Java
Creating a Simple, Multithreaded Chat System with Java Introduction by George Crawford III In this edition of Objective Viewpoint, you will learn how to develop a simple chat system. The program will demonstrate
System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :
Benjamin Michael Java Homework 3 10/31/2012 1) Sales.java Code // Sales.java // Program calculates sales, based on an input of product // number and quantity sold import java.util.scanner; public class
Object-Oriented Programming in Java
CSCI/CMPE 3326 Object-Oriented Programming in Java Class, object, member field and method, final constant, format specifier, file I/O Dongchul Kim Department of Computer Science University of Texas Rio
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
java.util.scanner Here are some of the many features of Scanner objects. Some Features of java.util.scanner
java.util.scanner java.util.scanner is a class in the Java API used to create a Scanner object, an extremely versatile object that you can use to input alphanumeric characters from several input sources
Some Scanner Class Methods
Keyboard Input Scanner, Documentation, Style Java 5.0 has reasonable facilities for handling keyboard input. These facilities are provided by the Scanner class in the java.util package. A package is a
13 File Output and Input
SCIENTIFIC PROGRAMMING -1 13 File Output and Input 13.1 Introduction To make programs really useful we have to be able to input and output data in large machinereadable amounts, in particular we have to
Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.
Scanner The Scanner class is intended to be used for input. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit. For example, suppose the input
CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
Chapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
D06 PROGRAMMING with JAVA
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch16 Files and Streams PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for
Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language
Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description
Building Java Programs
Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: 3.3-3.4 self-check: #16-19 exercises: #11 videos: Ch. 3 #4 Interactive programs We have written programs that print
Visit us at www.apluscompsci.com
Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/apluscomputerscience Scanner kb = new Scanner(System.in);
Topic 11 Scanner object, conditional execution
Topic 11 Scanner object, conditional execution "There are only two kinds of programming languages: those people always [complain] about and those nobody uses." Bjarne Stroustroup, creator of C++ Copyright
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
Chapter 3. Input and output. 3.1 The System class
Chapter 3 Input and output The programs we ve looked at so far just display messages, which doesn t involve a lot of real computation. This chapter will show you how to read input from the keyboard, use
File I/O - Chapter 10. Many Stream Classes. Text Files vs Binary Files
File I/O - Chapter 10 A Java stream is a sequence of bytes. An InputStream can read from a file the console (System.in) a network socket an array of bytes in memory a StringBuffer a pipe, which is an OutputStream
Sample CSE8A midterm Multiple Choice (circle one)
Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names
JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4
JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4 NOTE: SUN ONE Studio is almost identical with NetBeans. NetBeans is open source and can be downloaded from www.netbeans.org. I
The following program is aiming to extract from a simple text file an analysis of the content such as:
Text Analyser Aim The following program is aiming to extract from a simple text file an analysis of the content such as: Number of printable characters Number of white spaces Number of vowels Number of
Event-Driven Programming
Event-Driven Programming Lecture 4 Jenny Walter Fall 2008 Simple Graphics Program import acm.graphics.*; import java.awt.*; import acm.program.*; public class Circle extends GraphicsProgram { public void
Building Java Programs
Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: 3.3-3.4 self-check: #16-19 exercises: #11 videos: Ch. 3 #4 Interactive programs We have written programs that print
Lesson: All About Sockets
All About Sockets http://java.sun.com/docs/books/tutorial/networking/sockets/index.html Page 1 sur 1 The Java TM Tutorial Start of Tutorial > Start of Trail Trail: Custom Networking Lesson: All About Sockets
JAVA.UTIL.SCANNER CLASS
JAVA.UTIL.SCANNER CLASS http://www.tutorialspoint.com/java/util/java_util_scanner.htm Copyright tutorialspoint.com Introduction The java.util.scanner class is a simple text scanner which can parse primitive
Chapter 2. println Versus print. Formatting Output withprintf. System.out.println for console output. console output. Console Input and Output
Chapter 2 Console Input and Output System.out.println for console output System.out is an object that is part of the Java language println is a method invoked dby the System.out object that can be used
IMDB Data Set Topics: Parsing Input using Scanner class. Atul Prakash
IMDB Data Set Topics: Parsing Input using Scanner class Atul Prakash IMDB Data Set Consists of several files: movies.list: contains actors.list: contains aka-titles.list:
1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius
Programming Concepts Practice Test 1 1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius 2) Consider the following statement: System.out.println("1
Reading Input From A File
Reading Input From A File In addition to reading in values from the keyboard, the Scanner class also allows us to read in numeric values from a file. 1. Create and save a text file (.txt or.dat extension)
Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75
Preet raj Core Java and Databases CS4PR Time Allotted: 3 Hours Final Exam: Total Possible Points 75 Q1. What is difference between overloading and overriding? 10 points a) In overloading, there is a relationship
AP Computer Science File Input with Scanner
AP Computer Science File Input with Scanner Subset of the Supplement Lesson slides from: Building Java Programs, Chapter 6 by Stuart Reges and Marty Stepp (http://www.buildingjavaprograms.com/ ) Input/output
Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
Programming Languages CIS 443
Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception
Week 1: Review of Java Programming Basics
Week 1: Review of Java Programming Basics Sources: Chapter 2 in Supplementary Book (Murach s Java Programming) Appendix A in Textbook (Carrano) Slide 1 Outline Objectives A simple Java Program Data-types
Lecture J - Exceptions
Lecture J - Exceptions Slide 1 of 107. Exceptions in Java Java uses the notion of exception for 3 related (but different) purposes: Errors: an internal Java implementation error was discovered E.g: out
Comp 248 Introduction to Programming
Comp 248 Introduction to Programming Chapter 2 - Console Input & Output Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has been
READING DATA FROM KEYBOARD USING DATAINPUTSTREAM, BUFFEREDREADER AND SCANNER
READING DATA FROM KEYBOARD USING DATAINPUTSTREAM, BUFFEREDREADER AND SCANNER Reading text data from keyboard using DataInputStream As we have seen in introduction to streams, DataInputStream is a FilterInputStream
Homework/Program #5 Solutions
Homework/Program #5 Solutions Problem #1 (20 points) Using the standard Java Scanner class. Look at http://natch3z.blogspot.com/2008/11/read-text-file-using-javautilscanner.html as an exampleof using the
JAVA ARRAY EXAMPLE PDF
JAVA ARRAY EXAMPLE PDF Created By: Umar Farooque Khan 1 Java array example for interview pdf Program No: 01 Print Java Array Example using for loop package ptutorial; public class PrintArray { public static
MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION
MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION 1. Write a loop that computes (No need to write a complete program) 100 1 99 2 98 3 97... 4 3 98 2 99 1 100 Note: this is not the only solution; double sum
1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders
1.00 Lecture 1 Course Overview Introduction to Java Reading for next time: Big Java: 1.1-1.7 Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders
Using Two-Dimensional Arrays
Using Two-Dimensional Arrays Great news! What used to be the old one-floor Java Motel has just been renovated! The new, five-floor Java Hotel features a free continental breakfast and, at absolutely no
Building a Multi-Threaded Web Server
Building a Multi-Threaded Web Server In this lab we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous
AP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
public static void main(string[] args) { System.out.println("hello, world"); } }
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
Scanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard
INPUT & OUTPUT I/O Example Using keyboard input for characters import java.util.scanner; class Echo{ public static void main (String[] args) { Scanner sc = new Scanner(System.in); // scanner for the keyboard
Chapter 2: Elements of Java
Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
CS 111 Classes I 1. Software Organization View to this point:
CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects
Line-based file processing
Line-based file processing reading: 6.3 self-check: #7-11 exercises: #1-4, 8-11 Hours question Given a file hours.txt with the following contents: 123 Kim 12.5 8.1 7.6 3.2 456 Brad 4.0 11.6 6.5 2.7 12
AP Computer Science Java Mr. Clausen Program 9A, 9B
AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will
Part I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
Explain the relationship between a class and an object. Which is general and which is specific?
A.1.1 What is the Java Virtual Machine? Is it hardware or software? How does its role differ from that of the Java compiler? The Java Virtual Machine (JVM) is software that simulates the execution of a
Building Java Programs
Building Java Programs Chapter 4 Lecture 4-1: Scanner; if/else reading: 3.3 3.4, 4.1 Interactive Programs with Scanner reading: 3.3-3.4 1 Interactive programs We have written programs that print console
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui
Question R11.3. R11.3 How do you open a file whose name contains a backslash, like c:\temp\output.dat?
Chapter 11 Question R11.1: R11.1 What happens if you try to open a file for reading that doesn t exist? What happens if you try to open a file for writing that doesn t exist? The system throws an IOException
Files and input/output streams
Unit 9 Files and input/output streams Summary The concept of file Writing and reading text files Operations on files Input streams: keyboard, file, internet Output streams: file, video Generalized writing
Evaluation. Copy. Evaluation Copy. Chapter 7: Using JDBC with Spring. 1) A Simpler Approach... 7-2. 2) The JdbcTemplate. Class...
Chapter 7: Using JDBC with Spring 1) A Simpler Approach... 7-2 2) The JdbcTemplate Class... 7-3 3) Exception Translation... 7-7 4) Updating with the JdbcTemplate... 7-9 5) Queries Using the JdbcTemplate...
Basics of Java Programming Input and the Scanner class
Basics of Java Programming Input and the Scanner class CSC 1051 Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/
16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution
16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more
Continuous Integration Part 2
1 Continuous Integration Part 2 This blog post is a follow up to my blog post Continuous Integration (CI), in which I described how to execute test cases in Code Tester (CT) in a CI environment. What I
D06 PROGRAMMING with JAVA
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch15 Exception Handling PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for
Division of Informatics, University of Edinburgh
CS1Bh Lecture Note 20 Client/server computing A modern computing environment consists of not just one computer, but several. When designing such an arrangement of computers it might at first seem that
Data Structures Lecture 1
Fall 2015 Fang Yu Software Security Lab. Dept. Management Information Systems, National Chengchi University Data Structures Lecture 1 A brief review of Java programming Popularity of Programming Languages
LOOPS CHAPTER CHAPTER GOALS
jfe_ch04_7.fm Page 139 Friday, May 8, 2009 2:45 PM LOOPS CHAPTER 4 CHAPTER GOALS To learn about while, for, and do loops To become familiar with common loop algorithms To understand nested loops To implement
CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java
CS1020 Data Structures and Algorithms I Lecture Note #1 Introduction to Java Objectives Java Basic Java features C Java Translate C programs in CS1010 into Java programs 2 References Chapter 1 Section
J a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
Chapter 10. A stream is an object that enables the flow of data between a program and some I/O device or file. File I/O
Chapter 10 File I/O Streams A stream is an object that enables the flow of data between a program and some I/O device or file If the data flows into a program, then the stream is called an input stream
Question1-part2 What undesirable consequences might there be in having too long a DNS cache entry lifetime?
CSCI 312 - DATA COMMUNICATIONS AND NETWORKS FALL, 2014 Assignment 4 Working as a group. Working in small gruops of 2-4 students. When you work as a group, you have to return only one home assignment per
Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219
Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing
CS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 29 / 2014 Instructor: Michael Eckmann Today s Topics Comments and/or Questions? import user input using JOptionPane user input using Scanner psuedocode import
Iteration CHAPTER 6. Topic Summary
CHAPTER 6 Iteration TOPIC OUTLINE 6.1 while Loops 6.2 for Loops 6.3 Nested Loops 6.4 Off-by-1 Errors 6.5 Random Numbers and Simulations 6.6 Loop Invariants (AB only) Topic Summary 6.1 while Loops Many
Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.
Software Testing Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Testing can only reveal the presence of errors and not the
Building Java Programs
Building Java Programs Chapter 5 Lecture 5-2: Random Numbers reading: 5.1-5.2 self-check: #8-17 exercises: #3-6, 10, 12 videos: Ch. 5 #1-2 1 The Random class A Random object generates pseudo-random* numbers.
6.1. Example: A Tip Calculator 6-1
Chapter 6. Transition to Java Not all programming languages are created equal. Each is designed by its creator to achieve a particular purpose, which can range from highly focused languages designed for
Fundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html
CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install
Quick Introduction to Java
Quick Introduction to Java Dr. Chris Bourke Department of Computer Science & Engineering University of Nebraska Lincoln Lincoln, NE 68588, USA Email: [email protected] 2015/10/30 20:02:28 Abstract These
Exception Handling. Overloaded methods Interfaces Inheritance hierarchies Constructors. OOP: Exception Handling 1
Exception Handling Error handling in general Java's exception handling mechanism The catch-or-specify priciple Checked and unchecked exceptions Exceptions impact/usage Overloaded methods Interfaces Inheritance
www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk
CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling
Introduction to Java. CS 3: Computer Programming in Java
Introduction to Java CS 3: Computer Programming in Java Objectives Begin with primitive data types Create a main class with helper methods Learn how to call built-in class methods and instance methods
Chapter 2 Elementary Programming
Chapter 2 Elementary Programming 2.1 Introduction You will learn elementary programming using Java primitive data types and related subjects, such as variables, constants, operators, expressions, and input
Programming and Data Structures with Java and JUnit. Rick Mercer
Programming and Data Structures with Java and JUnit Rick Mercer ii Chapter Title 1 Program Development 2 Java Fundamentals 3 Objects and JUnit 4 Methods 5 Selection (if- else) 6 Repetition (while and for
Interactive Programs and Graphics in Java
Interactive Programs and Graphics in Java Alark Joshi Slide credits: Sami Rollins Announcements Lab 1 is due today Questions/concerns? SVN - Subversion Versioning and revision control system 1. allows
CS 2112 Spring 2014. 0 Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions
CS 2112 Spring 2014 Assignment 3 Data Structures and Web Filtering Due: March 4, 2014 11:59 PM Implementing spam blacklists and web filters requires matching candidate domain names and URLs very rapidly
CS170 Lab 11 Abstract Data Types & Objects
CS170 Lab 11 Abstract Data Types & Objects Introduction: Abstract Data Type (ADT) An abstract data type is commonly known as a class of objects An abstract data type in a program is used to represent (the
Assignment 4 Solutions
CSCI 312 - DATA COMMUNICATIONS AND NETWORKS FALL, 2014 Assignment 4 Solutions Working as a pair Working in pairs. When you work as a pair you have to return only one home assignment per pair on a round.
WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.
WA2099 Introduction to Java using RAD 8.0 Student Labs Web Age Solutions Inc. 1 Table of Contents Lab 1 - The HelloWorld Class...3 Lab 2 - Refining The HelloWorld Class...20 Lab 3 - The Arithmetic Class...25
Chapter 20 Streams and Binary Input/Output. Big Java Early Objects by Cay Horstmann Copyright 2014 by John Wiley & Sons. All rights reserved.
Chapter 20 Streams and Binary Input/Output Big Java Early Objects by Cay Horstmann Copyright 2014 by John Wiley & Sons. All rights reserved. 20.1 Readers, Writers, and Streams Two ways to store data: Text
CS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper
Outline. 1 Denitions. 2 Principles. 4 Implementation and Evaluation. 5 Debugging. 6 References
Outline Computer Science 331 Introduction to Testing of Programs Mike Jacobson Department of Computer Science University of Calgary Lecture #3-4 1 Denitions 2 3 4 Implementation and Evaluation 5 Debugging
