CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
|
|
|
- Hector Burke
- 9 years ago
- Views:
Transcription
1 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100) 1. (3 pts each, 18 pts total) What is the value of the variable answer after each of the following statements given the declarations below. These are tricky - pay special attention to variable types! double answer = 10; double x = 4; double y = 3; int n = 2; int m = 7; a. answer += 2.5; answer = = 12.5 b. answer = n % m; answer = 2 % 7 = 2 c. answer = m % n; answer = 7 % 2 = 1 d. answer = 4*n/m; answer = 4*2/7 = 8/7 = 1 e. answer = 1 + y/x; answer = /4.0 = 1.75 f. answer = n/x; answer = 2 /4.0 =.5
2 Oct 4, 2013, p 2 2. (1 pt each, 12 pts total) For each definition, identify the index (e.g. A, B, ) of the vocabulary word it describes. Please write clearly so your answer is unambiguous. Definitions: i. S) Variable A named location in memory for holding data. ii. Q) String A sequence of characters. iii. K) Magic Number A number that appears in code without explanation. iv. O) API The place a programmer can look at to read about a class s methods. v. M) Primitive Type A variable type which contains a only single value, e.g. int, double or char as opposed to String or Scanner vi. J) Concatenation Combining strings to form a new string. vii. T) Lexicographic The way Java compares and orders strings. (Note, I gave credit for P as well although it isn t specific to strings) viii. H) Cast Explicitly converting a value from one type to a different type. ix. I) Character A single letter, digit or symbol (e.g. ascii code). x. G) Sentinel An input value that is used to signal the end of input. xi. F) Runtime Error An error in a syntactically correct program that causes it to act differently from specification. xii. L) Initialization Setting the value of a variable for the first time, before it is used. Vocabulary Word A. Assignment B. Expression C. Boolean value D. Relational operator E. Compile time error F. Run-time error G. Sentinel H. Cast I. Character J. Concatenation K. Magic Number L. Initialization M. Primitive type N. Class type O. Application programming interface (API) documentation (Javadoc) P. Boolean operator Q. A String R. Type S. Variable T. Lexicographic
3 Oct 4, 2013, p 3 3. (4 pts each, 24 pts) Given the declarations: int x; int y; char c; String answer; String word1; String word2; Write a Boolean expression for the following: a. The answer begins with the letter Z answer.charat(0) == Z alternatively: answer.substring(0,1).equals( Z ) b. The mathematical expression 20 < x < < x && x < 100 c. The character c is the letter E or e c == E c == e d. word1 does not equal word2! word1.equals(word2) e. It is not true that x and y are both less than 10!(x<10 && y<10) same as!(x<10)!(y<10) same as x>=10 y >=10 f. y is either less than 100 or more than 200. y < 100 y > (4 pts each, 16 pts total) What is the output of the following loops? Briefly explain your answers (otherwise, no partial credit can be given if your answer is not quite right!) Loop 1: int cnt = 0; for (int j = 10; j < 15; j++) cnt++; System.out.println("cnt = " + cnt); Loop 1 Output: j executes = 5 times, i.e. for values j = 10, 11, 12, 13, 15 cnt = 5
4 Oct 4, 2013, p 4 Loop 2: int cnt = 0; for (int j = 5; j < 15; j++) for (int i = 0; i < 10; i++) cnt++; System.out.println("cnt = " + cnt); Loop 2 Output: inner loop loops 10 times, outer loop loops 10 times, so cnt is incremented 100 times cnt = 100 Loop 3: int cnt = 0; for (int j = 0; j < 4; j++) for (int i = 0; i < j; i++) cnt++; System.out.println("cnt = " + cnt); Loop 3 Output: Values of i and j are j = 0: i = no loop j = 1: i = 0 j = 2: i = 0, 1 j = 3: i = 0, 1, 2 thus we have cnt = 6 Loop 4: int cnt = 0; for (int j = 0; j < 4; j++) for (int i = 0; i < 5; i++) for (int k = 0; k < 10; k++) cnt++; System.out.println("cnt = " + cnt); Loop 4 Output: j loop: 4 times, i loop: 5 times, k loop: 10 times So that cntis incremented 4x5x10 = 200 times cnt = 200
5 Oct 4, 2013, p 5 5. (12 pts) Write a while-loop which sums the integers from a to b (inclusive) and prints the result once at the very end. import java.util.scanner; public class LoopPractice public static void main(string[] args) Scanner in = new Scanner(System.in); System.out.print("Enter 2 integers: "); int a = in.nextint(); int b = in.nextint(); int sum = 0; while (a <= b) sum = sum + a; a++; System.out.println("sum = " + sum); Could also have done (this is better if you later on need the value of a): int sum = 0; int i = a; while( i <= b ) sum = sum + i; i++; System.out.println("sum = " + sum); 6. (18 pts total) Multiple Choice - Circle the correct answer. (Please be clear! Ambiguous or hard to read answers will be counted as incorrect.) A. (1 pt) Which one of the following errors represents a part of a program that is incorrect according to the rules of the programming language? a) Syntax errors c) Logic errors b) Run-time errors d) Out-of-memory errors B. (1 pt) Which one of the following types of statements is an instruction to replace the existing value of a variable with another value? a) Update c) Assignment b) Declaration d) Initialization Note: Will give credit for a) as well, although c) is a better answer.
6 Oct 4, 2013, p 6 C. (1 pt) What is wrong with the following code snippet? public class Area public static void main(string[] args) int width = 10; height = 20.00; System.out.println("area = " + (width * height)); a) The code snippet uses an uninitialized variable. b) The code snippet uses an undeclared variable. c) The code snippet attempts to assign a decimal value to an integer variable. d) The code snippet attempts to add a number to a string variable. D. (2 pts) What is the output of the following code snippet? public static void main(string[] args) String str1 = "I LOVE Willamette"; String str2 = str1.substring(4, 9); System.out.println(str2); a) I LOV c) VE Wil b) OVE W d) VE Wi E. (1 pt) What will be the output when the following code is executed double x = 2.5; double y = 0.0; if ( y!= 0 && x/y!= 1.0) System.out.println( x/y is not equal to 1 ); else System.out.println( x/y is equal to 1 ); a) x/y is not equal to 1 c) There will be no output. b) x/y is equal to 1 d) The program will crash.
7 Oct 4, 2013, p 7 F. (1 pt) What kind of operator is the <= operator? a) Boolean c) Inequality b) Arithmetic d) Relational G. (1 pt) Which of the following options refers to the technique of simulating program execution on a sheet of paper? a) Compiling c) Tracing b) Prototyping d) Debugging H. (1 pt) Which of the following loops executes the statements inside the loop before checking the condition? a) for c) do-while b) while d) do-for I. (2 pts) Assuming that a user enters 25 as the value for x, what is the output of the following code snippet? Scanner in = new Scanner(System.in); System.out.print("Enter a number: "); int x = in.nextint(); if (x < 100) x = x + 5; if (x < 500) x = x - 2; if (x > 10) x++; else x--; System.out.println(x); a) 27 c) 29 b) 28 d) 30 J. (1 pt) Which of the following loop(s) could possibly not enter the loop body at all? I. for loop II. while loop III. do-while loop a) I only c) II and III only b) I and II only d) I and III only
8 Oct 4, 2013, p 8 K. (1 pt) A loop inside another loop is called: a) A sentinel loop c) A parallel loop b) A nested loop d) A do/while loop L. (2 pts) What is the output of the following loop? for (int i = 20; i >= 2; i = i - 6) System.out.print(i + ", "); a) 20, 14, 8, c) 20, 14, 8, 2, b) 14, 8, d) 14, 8, 2, M. (2 pts) What is the first and last value of i to be printed by the following code snippet? int n = 20; for (int i = 0; i <= n; i++) for (int j = 0; j <= i; j++) System.out.println("" + i); a) 0 and 20 c) 1 and 19 e) None of the above b) 1 and 20 d) 0 and 19 N. (1 pt) What will be the output of the following code snippet? boolean token = false; while (token) System.out.println("Hello"); a) Hello will be displayed infinite times. c) No output after successful compilation. b) No output because of compilation error. d) Hello will be displayed only once. O. (2 pts) What is the output of the following code: int x = 7; int y = 9; int z = 5; x = y; y = z; z = x; System.out.println(x + " " + y + " " + z); a) c) b) d) 7 7 7
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
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
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
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
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
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
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
CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement
CompSci 125 Lecture 08 Chapter 5: Conditional Statements Chapter 4: return Statement Homework Update HW3 Due 9/20 HW4 Due 9/27 Exam-1 10/2 Programming Assignment Update p1: Traffic Applet due Sept 21 (Submit
CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals
CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]
AP Computer Science Static Methods, Strings, User Input
AP Computer Science Static Methods, Strings, User Input Static Methods The Math class contains a special type of methods, called static methods. A static method DOES NOT operate on an object. This is because
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
Introduction to Programming
Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems [email protected] Spring 2015 Week 2b: Review of Week 1, Variables 16 January 2015 Birkbeck
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
Java Basics: Data Types, Variables, and Loops
Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables
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
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
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
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
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 ******
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
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
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
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
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
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
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
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
COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19
Term Test #2 COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005 Family Name: Given Name(s): Student Number: Question Out of Mark A Total 16 B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 C-1 4
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
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
Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:
Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of
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
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
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
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
Computer Programming I
Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,
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
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
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
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
Variables, Constants, and Data Types
Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class: L&L, 2.1-2.3, App C 1 Primitive Data There are eight
Semantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
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
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui
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
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
Informatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction
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
Introduction to Java Lecture Notes. Ryan Dougherty [email protected]
1 Introduction to Java Lecture Notes Ryan Dougherty [email protected] Table of Contents 1 Versions....................................................................... 2 2 Introduction...................................................................
We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.
LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.
Example of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
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
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman
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
Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:
In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our
Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C
Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in
VB.NET Programming Fundamentals
Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements
Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts
Third AP Edition Object-Oriented Programming and Data Structures Maria Litvin Phillips Academy, Andover, Massachusetts Gary Litvin Skylight Software, Inc. Skylight Publishing Andover, Massachusetts Skylight
Java Programming Fundamentals
Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few
Crash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
(Eng. Hayam Reda Seireg) Sheet Java
(Eng. Hayam Reda Seireg) Sheet Java 1. Write a program to compute the area and circumference of a rectangle 3 inche wide by 5 inches long. What changes must be made to the program so it works for a rectangle
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
Visual Logic Instructions and Assignments
Visual Logic Instructions and Assignments Visual Logic can be installed from the CD that accompanies our textbook. It is a nifty tool for creating program flowcharts, but that is only half of the story.
Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane.
Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6 Handout 3 Strings and String Class. Input/Output with JOptionPane. Strings In Java strings are represented with a class type String. Examples:
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything
Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)
Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking
Statements and Control Flow
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
Computer Programming I
Computer Programming I Levels: 10-12 Units of Credit: 1.0 CIP Code: 11.0201 Core Code: 35-02-00-00-030 Prerequisites: Secondary Math I, Keyboarding Proficiency, Computer Literacy requirement (e.g. Exploring
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.
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
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
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
High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
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
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
An Introduction to Assembly Programming with the ARM 32-bit Processor Family
An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2
Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
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/
Programmierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 21 10/16/2012 09:29 AM Java - A First Glance 2 of 21 10/16/2012 09:29 AM programming languages
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
Unit 6. Loop statements
Unit 6 Loop statements Summary Repetition of statements The while statement Input loop Loop schemes The for statement The do statement Nested loops Flow control statements 6.1 Statements in Java Till now
While and Do-While Loops. 15-110 Summer 2010 Margaret Reid-Miller
While and Do-While Loops 15-110 Margaret Reid-Miller Loops Within a method, we can alter the flow of control using either conditionals or loops. The loop statements while, do-while, and for allow us execute
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
Conditionals (with solutions)
Conditionals (with solutions) For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87;
Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
While Loop. 6. Iteration
While Loop 1 Loop - a control structure that causes a set of statements to be executed repeatedly, (reiterated). While statement - most versatile type of loop in C++ false while boolean expression true
Lecture 1 Introduction to Java
Programming Languages: Java Lecture 1 Introduction to Java Instructor: Omer Boyaci 1 2 Course Information History of Java Introduction First Program in Java: Printing a Line of Text Modifying Our First
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
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
Programming in Java. 2013 Course Technology, a part of Cengage Learning.
C7934_chapter_java.qxd 12/20/11 12:31 PM Page 1 Programming in Java Online module to accompany Invitation to Computer Science, 6th Edition ISBN-10: 1133190820; ISBN-13: 9781133190820 (Cengage Learning,
This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output: 1 2 3 4 5 6 7 8 9 10
Java Loops & Methods The while loop Syntax: while ( condition is true ) { do these statements Just as it says, the statements execute while the condition is true. Once the condition becomes false, execution
Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing.
Computers An Introduction to Programming with Python CCHSG Visit June 2014 Dr.-Ing. Norbert Völker Many computing devices are embedded Can you think of computers/ computing devices you may have in your
Java Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
Computer Programming I & II*
Computer Programming I & II* Career Cluster Information Technology Course Code 10152 Prerequisite(s) Computer Applications, Introduction to Information Technology Careers (recommended), Computer Hardware
IRA EXAMPLES. This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account).
IRA EXAMPLES This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account). Definite Counting Loop Example IRA After x Years This first example illustrates
