1. True or False. If false, give an explanation. a. Integer and decimal numbers can be mixed in an expression. True
|
|
- Arron Hardy
- 5 years ago
- Views:
Transcription
1 Chapter 2 Crossword Solution Short Answers 1. True or False. If false, give an explanation. a. Integer and decimal numbers can be mixed in an expression. True b. Integers can be added to character data. True c. Boolean data can be cast to integer data. False Boolean data is not 0 or 1, and cannot be cast to int. d. The relational operators cannot be used with character data. False They can. Characters are compared by ASCII value, which is alphabetically ordered. e. If only one decimal number is used with the / (division) operator, the result is an integer. False The result is float or double depending on the type of the decimal number. Two integers are needed to result in an integer. f. It makes no difference whether one uses 5 or 5.0 in a numerical expression. False It makes a great difference. The value 5 is int and the value 5.0 is double, so the type of the expression may depend on which is used.
2 g. The decimal form of 23.00E6 is False No. It is h. The argument to println must be a string. False. Java specifies that the print and println methods accept a single argument of any type. i. Two boolean expressions may be compared using <. False. The < operator cannot be applied to boolean operands j. The plus operator may be used with two strings. True the operation is concatenation. 2. Playing Compiler Evaluate each of the following expressions or determine that the expression is ill formed. a * / b. true false && 3 < 4!(5 == 7) true c. true (3 < 5 && 6 >= 2) true d.!true > A Ill formed e. 7 % / 6 * Z 6 f. D M % 2 / 3 69 g. 5.0 / 3 + 3/ h. 53 % 21 < 45 /18 false i. (4 < 6) true && false false && (2 > 3) true
3 j. 7 (3 + 8 * 6 + 3) (2 + 5 * 2) Playing Compiler Determine which of the following Java statements/segments are incorrect. If a statement is correct, give the output. If incorrect, explain why. a. System.out.print ("May 13, 1988 fell on day number "); May 13, 1988 fell on day number b. System.out.println( ((13 + (13 * 3-1) / % % 100 / / * (1988 / 100)) % 7 + 7) % 7 ); 5 c. System.out.print ("Check out this line "); Check out this line d. System.out.println( "//hello there " + '9' + 7 ); //hello there97 e. System.out.print( 'H' + 'I' + " is " "more example"); 145 is 1more example f. System.out.print( 'H' 'I' + " is " "more example"); is 1more example g. System.out.print("Print both of us", "Me too"); Incorrect: the print method in System.out expects one string, not two. h. System.out.print( "Reverse " + 'I' + 'T' ); Reverse IT i. System.out.print("No! Here is" "more example");
4 No! Here is1more example j. System.out.println ("Here is " + 10*10)) // that s 100 ; Incorrect: semi-colon should appear before the comment in place of the last close paren. k. System.out.println("Not x is " + true); // that s true. Not x is true l. System.out.print(); Incorrect: illegal number of arguments (must have a string argument). m. System.out.println; Incorrect: println is a method of System.out, not a field, and so needs () following it. Note, println, unlike print, may have no arguments, so System.out.println(); is correct.. n. System.out.print("How about this one" + '?' + 'Huh? ' ); Incorrect: Huh? needs double quotes around it because it is a string. Single quotes cause the compiler to complain of an unexpected symbol. 4. Playing Compiler Find and correct the errors in the following program: public class LeapYear; { public static void main(string args) { System.out.print("The year 2300 is a leap year? " + "True or false: "); // (divisible by 4 and not by 100) or (divisible by 400) // System.out.println( 2300 % 4 = 0 && 1800 % 100!= % 400 == 0); } Line 1: Extraneous semicolon at the end of public class LeapYear Line 3: [] is needed after String Line 7: 2300%4 =0 should be 2300%4 == 0 The two 1800 s should each be Line 9: Missing the closing bracket at end of the program. 5. Parentheses and Operator Precedence
5 Fully parenthesize each of the following expressions to reflect operator precedence. a (((2+3)+4)+5) b. 3*4+5/6-7 (((3*4) + (5/6)) 7) c. 2+3*4*5 (2+ ((3*4)*5)) d. 9%2/2*3 (((9%2)/2)* 3) e. 7+6*4%2+3*5 ((7 + ((6*4)%2)) + (3*5)) f. true false true && false ((true false) (true && true)) 6. Boolean Expressions Compute the value of each of the following boolean expressions. Recall that Java uses short circuit evaluation. For each expression determine how much of the expression Java must evaluate to determine a value. a. true && false &&true true true (the second && is never evaluated) b. true true && true && false true (the is not evaluated) c. (true && false) (true &&! false) (false &&!false) true (the second and third && are not evaluated) d. (2 < 3) (5 > 2) &&!(4 == 4) 9!= 4 true (the first and second are not evaluated) e. 6 == 9 5 < 6 && 8 < 4 4 > 3 true (the whole expression is evaluated)
6 7. Boolean Expressions Write a Java boolean expression that models each of the following circuit diagrams. See Example 2.9. (x!y) && (!x && y!x &&!y) (x &&!y!x) && (!x && y x!y) 8. Playing Compiler Determine which of the following expressions are valid. For each valid expression give the data type of the resulting value. a. 27/ b. 27/ c. 42.7% d. (3<4) && 5/8 Invalid incompatible types. e. 23/5 + 23/ f a 99.0
7 g. 2 + a 99 h. a + b 195 i. a / b 0 j. a &&! b Invalid - && operates only on boolean types k. (double) a / b DeMorgan s Law DeMorgan s Laws for boolean expressions state that!(a && b) is equivalent to!a! b, and!(a b) is equivalent!a &&! b Use DeMorgan s Laws to simplify the following boolean expressions: a.!(a!b)!a && b b.!(!a &&!b) a b c.!(!a!b) a && b d.!((a&&b) (!a &&!b)) (!a!b) && (a b) 10. What s the Ourput? Determine the output of the following program: public class Memory { public static void main(string[] args) { System.out.print ("There once was a girl named Elaine\n"); System.out.print ("With a microchip lodged in her brain\n"); System.out.print ("\ther friends were amazed\n"); System.out.print ("\tbedazzled and dazed\n"); System.out.print ("By the facts that Elaine could retain\n"); }
8 } There once was a girl named Elaine With a microchip lodged in her brain Her friends were amazed Bedazzled and dazed By the facts that Elaine could retain 11. What s the Output? Determine the values of each of the following Java expressions: a. 7/3*2 4 b. 7/(3*2) 1 c. 7.0/3* d. 7/3* e. 7/(3*2.0) f. 7.0/3.0* g. (7/3)*2 4 h. (7.0/3)* Comments Debugging a program can be a long and intricate process. Can you think of how you might use Java comments as an aid to debugging? What are some other ways that you might use Java comments? Obviously it is helpful to use comments to clarify your intended meaning of a segment of code. The notes you leave will help others, and they will likely help you too after a number of months pass before you have to find a bug.
9 Also, comments can be used to comment out lines of code that you suspect are not relevant to the bug at hand, allowing you to run the program concentrating only on the offending lines. The commented out lines will not execute. After the bug is found the comments can be taken out, and the code reestablished The Bigger Picture Binary Encoding ASCII 1. How many binary numbers are there with 4 bits? 10 bits? n bits? 16, 1024, 2 n. 2. How many different characters are included in the ASCII coding scheme? Many electronic devices, such as calculators and digital clocks, display no symbols other than the digits 0 through 9. With only ten possible symbols, the 7-bit ASCII code is overkill. We can use fewer than 7 bits per digit. How many bits can be used to encode a digit in a calculator or clock? Using this number of bits per digit, how many digits can be stored in one byte? This type of encoding is called BCD, or binary coded decimal, and it is twice as compact as ASCII encoding. 4 bits per digit, and therefore two digits per byte. 4. How many different characters can be represented using the 16-bit Unicode system? Explain your answer. 2^16 = 65, Considering Hebrew, Arabic, Cyrillic, Greek, Sanskrit, and Kanji symbols, conjecture whether the number of Unicode values is reasonably large enough to include all the characters that humans use for written communication. Can you think of any reasons for converting to a 64-bit character code? 60,000 is plenty for alphabets of all current languages except for Kanji symbols used in Chinese and Japanese writing. A complete catalog of all Kanji includes up to 80,000 synbols. Nevertheless, a typical person s Kanji vocabulary is far less than this, and less than 7000 Kanji symbols are enough for any practical use. Hence, 16 bits will suffice for the indefinite future. 2^64 is such a huge number, that it is inconceivable we would ever need to store that many unique characaters or symbols. 6. Determine the ASCII code for the four-digit string "1026". Use one byte for each digit
10 7. Determine the binary equivalent of the decimal number What are the advantages and disadvantages of storing a string of digits using ASCII rather than its binary number encoding? ASCII requires more space, but is easier to decode for printing digits. Binary number encoding is more compact and allows for efficient arithmetic calculation and manipulation. 9. How do you think digits in a Java program are stored? For example, are digits that are part of a class name stored in the same way as the digits that comprise an integer in an arithmetic expression? Use the following example to explain your answer. The first two occurrences of are stored in 5 bytes using ASCII, the third occurrence is stored as the binary number equivalent of decimal Binary Encoding Decimal 1. Give the decimal equivalents of , , and , 127, and Which characters are encoded by the ASCII and Unicode values in exercise 1? backslash, DEL key, and the backslash. 3. Determine the 7-bit binary equivalent of What is the 16-bit binary equivalent of 10,000? Boolean Types 1. Is it true that if a, b, and c are boolean then a (b && c) is equivalent to (a b) && (a c)? Yes. You can try all 8 true/false combinations for a,b, and c to confirm that the two expressions are equivalent. 2. Is it true that if a, b, and c are integers then a + (b * c) is equivalent to (a + b) * (a + c)? No, not in general. 3+(7*2) = 17 does not equal (3+7)*(3+2) = 50, for example.
11 3. The exclusive-or (XOR) operation on two Boolean operands is defined to be true whenever exactly one of the two operands is true. Write a Java boolean expression that calculates the exclusive-or of two boolean operands x and y. (x y) &&!(x && y), or equivalently, (!x && y) (x &&!y)
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationJAVA OPERATORS GENERAL
JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationBasic Operations jgrasp debugger Writing Programs & Checkstyle
Basic Operations jgrasp debugger Writing Programs & Checkstyle Suppose you wanted to write a computer game to play "Rock, Paper, Scissors". How many combinations are there? Is there a tricky way to represent
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationCONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2
CONTENTS: Compilation Data and Expressions COMP 202 More on Chapter 2 Programming Language Levels There are many programming language levels: machine language assembly language high-level language Java,
More informationExpressions and Data Types CSC 121 Spring 2017 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2017 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More information1007 Imperative Programming Part II
Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be
More informationLecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University
Lecture 2 COMP1406/1006 (the Java course) Fall 2013 M. Jason Hinek Carleton University today s agenda a quick look back (last Thursday) assignment 0 is posted and is due this Friday at 2pm Java compiling
More informationChapter 02: Using Data
True / False 1. A variable can hold more than one value at a time. ANSWER: False REFERENCES: 54 2. The int data type is the most commonly used integer type. ANSWER: True REFERENCES: 64 3. Multiplication,
More informationOutline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.
OOP in Java 1 Outline 1. Getting started, primitive data types and control structures 2. Classes and objects 3. Extending classes 4. Using some standard packages 5. OOP revisited Parts 1 to 3 introduce
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationOperators. Java operators are classified into three categories:
Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.
More information1 class Lecture2 { 2 3 "Elementray Programming" / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch.
1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 41 / 68 Example Given the radius
More informationJava provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:
Basic Operators Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationBuilding Java Programs. Chapter 2: Primitive Data and Definite Loops
Building Java Programs Chapter 2: Primitive Data and Definite Loops Copyright 2008 2006 by Pearson Education 1 Lecture outline data concepts Primitive types: int, double, char (for now) Expressions: operators,
More informationCOMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods
COMP-202 Unit 2: Java Basics CONTENTS: Using Expressions and Variables Types Strings Methods Assignment 1 Assignment 1 posted on WebCt and course website. It is due May 18th st at 23:30 Worth 6% Part programming,
More informationJava Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2
Java Foundations Introduction to Program Design and Data Structures 4th Edition Lewis TEST BANK Full download at : https://testbankreal.com/download/java-foundations-introduction-toprogram-design-and-data-structures-4th-edition-lewis-test-bank/
More informationB.V. Patel Institute of BMC & IT, UTU 2014
BCA 3 rd Semester 030010301 - Java Programming Unit-1(Java Platform and Programming Elements) Q-1 Answer the following question in short. [1 Mark each] 1. Who is known as creator of JAVA? 2. Why do we
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationChapter 6 Primitive types
Chapter 6 Primitive types Lesson page 6-1. Primitive types Question 1. There are an infinite number of integers, so it would be too ineffient to have a type integer that would contain all of them. Question
More informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
More informationCSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI
CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More informationLecture Set 2: Starting Java
Lecture Set 2: Starting Java 1. Java Concepts 2. Java Programming Basics 3. User output 4. Variables and types 5. Expressions 6. User input 7. Uninitialized Variables 0 This Course: Intro to Procedural
More informationLecture Set 2: Starting Java
Lecture Set 2: Starting Java 1. Java Concepts 2. Java Programming Basics 3. User output 4. Variables and types 5. Expressions 6. User input 7. Uninitialized Variables 0 This Course: Intro to Procedural
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationPrimitive Data, Variables, and Expressions; Simple Conditional Execution
Unit 2, Part 1 Primitive Data, Variables, and Expressions; Simple Conditional Execution Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Overview of the Programming Process Analysis/Specification
More informationMODULE 02: BASIC COMPUTATION IN JAVA
MODULE 02: BASIC COMPUTATION IN JAVA Outline Variables Naming Conventions Data Types Primitive Data Types Review: int, double New: boolean, char The String Class Type Conversion Expressions Assignment
More information4 Programming Fundamentals. Introduction to Programming 1 1
4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationCOMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015
COMP-202: Foundations of Programming Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 Announcements Midterm Exams on 4 th of June (12:35 14:35) Room allocation will be announced soon
More informationBuilding Java Programs
Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading: 2.1-2.2 1 Data and expressions reading: 2.1 self-check: 1-4 videos: Ch. 2 #1 2 Data types type: A category or set of data
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationZheng-Liang Lu Java Programming 45 / 79
1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 45 / 79 Example Given a radius
More informationCOSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand
COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site I have decided to keep this site for the whole semester I still hope to have blackboard up and running, but you
More informationBuilding Java Programs
Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading: 2.1-2.2 Copyright 2009 by Pearson Education Data and expressions reading: 2.1 self-check: 1-4 videos: Ch. 2 #1 Copyright
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationIntroduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language
Chapter 1 Getting Started Introduction To Java Most people are familiar with Java as a language for Internet applications We will study Java as a general purpose programming language The syntax of expressions
More informationCIS 110: Introduction to Computer Programming
CIS 110: Introduction to Computer Programming Lecture 3 Express Yourself ( 2.1) 9/16/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline 1. Data representation and types 2. Expressions 9/16/2011
More informationProf. Navrati Saxena TA: Rochak Sachan
JAVA Prof. Navrati Saxena TA: Rochak Sachan Operators Operator Arithmetic Relational Logical Bitwise 1. Arithmetic Operators are used in mathematical expressions. S.N. 0 Operator Result 1. + Addition 6.
More informationDATA TYPES AND EXPRESSIONS
DATA TYPES AND EXPRESSIONS Outline Variables Naming Conventions Data Types Primitive Data Types Review: int, double New: boolean, char The String Class Type Conversion Expressions Assignment Mathematical
More informationOperators in java Operator operands.
Operators in java Operator in java is a symbol that is used to perform operations and the objects of operation are referred as operands. There are many types of operators in java such as unary operator,
More informationLecture Set 4: More About Methods and More About Operators
Lecture Set 4: More About Methods and More About Operators Methods Definitions Invocations More arithmetic operators Operator Side effects Operator Precedence Short-circuiting main method public static
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationTopics. Chapter 5. Equality Operators
Topics Chapter 5 Flow of Control Part 1: Selection Forming Conditions if/ Statements Comparing Floating-Point Numbers Comparing Objects The equals Method String Comparison Methods The Conditional Operator
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 informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University January 15, 2015 Chapter 2: Data and Expressions CS 121 1 / 1 Chapter 2 Part 1: Data
More informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationCOSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 123 Computer Creativity Introduction to Java Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) Introduce Java, a general-purpose programming language,
More informationJava Bytecode (binary file)
Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.
More informationLecture Notes. System.out.println( Circle radius: + radius + area: + area); radius radius area area value
Lecture Notes 1. Comments a. /* */ b. // 2. Program Structures a. public class ComputeArea { public static void main(string[ ] args) { // input radius // compute area algorithm // output area Actions to
More informationData and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:
Data and Expressions Data and Expressions Let's explore some other fundamental programming concepts Chapter 2 focuses on: Character Strings Primitive Data The Declaration And Use Of Variables Expressions
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationOct Decision Structures cont d
Oct. 29 - Decision Structures cont d Programming Style and the if Statement Even though an if statement usually spans more than one line, it is really one statement. For instance, the following if statements
More informationCS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 05 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions / Comments? recap and some more details about variables, and if / else statements do lab work
More informationCMPT 125: Lecture 3 Data and Expressions
CMPT 125: Lecture 3 Data and Expressions Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Character Strings A character string is an object in Java,
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Chapter 2: Data and Expressions CS 121 1 / 51 Chapter 1 Terminology Review
More information3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
More informationBuilding Java Programs
Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading: 2.1-2.2 1 2 Data and expressions reading: 2.1 3 The computer s view Internally, computers store everything as 1 s and 0
More informationTOPIC 2 INTRODUCTION TO JAVA AND DR JAVA
1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared
More informationAlgorithms and Programming I. Lecture#12 Spring 2015
Algorithms and Programming I Lecture#12 Spring 2015 Think Python How to Think Like a Computer Scientist By :Allen Downey Installing Python Follow the instructions on installing Python and IDLE on your
More informationOperators and Expressions
Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 2: Data and Expressions CS 121 1 / 53 Chapter 2 Part 1: Data Types
More informationJava provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:
JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationVisual C# Instructor s Manual Table of Contents
Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms
More informationFirst Java Program - Output to the Screen
First Java Program - Output to the Screen These notes are written assuming that the reader has never programmed in Java, but has programmed in another language in the past. In any language, one of the
More informationEntry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process
Entry Point of Execution: the main Method Elementary Programming EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG For now, all your programming exercises will
More informationChapter 2 Elementary Programming
Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical
More informationImportant Java terminology
1 Important Java terminology The information we manage in a Java program is either represented as primitive data or as objects. Primitive data פרימיטיביים) (נתונים include common, fundamental values as
More informationJava Notes. 10th ICSE. Saravanan Ganesh
Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses
More informationLecture Set 4: More About Methods and More About Operators
Lecture Set 4: More About Methods and More About Operators Methods Definitions Invocations More arithmetic operators Operator Side effects Operator Precedence Short-circuiting main method public static
More informationVariables, Constants, and Data Types
Variables, Constants, and Data Types Strings and Escape Characters Primitive Data Types Variables, Initialization, and Assignment Constants Reading for this lecture: Dawson, Chapter 2 http://introcs.cs.princeton.edu/python/12types
More informationComputer Programming, I. Laboratory Manual. Final Exam Solution
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Final Exam Solution
More informationLecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18
Assignment Lecture 9 Logical Operations Formatted Print Printf Increment and decrement Read through 3.9, 3.10 Read 4.1. 4.2, 4.3 Go through checkpoint exercise 4.1 Logical Operations - Motivation Logical
More informationCOMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette
COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.
More informationAn overview of Java, Data types and variables
An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public
More informationObjects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003
Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 Java Programs A Java program contains at least one class definition. public class Hello { public static void
More informationA Java program contains at least one class definition.
Java Programs Identifiers Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 A Java program contains at least one class definition. public class Hello { public
More informationEXPRESSIONS AND ASSIGNMENT CITS1001
EXPRESSIONS AND ASSIGNMENT CITS1001 Scope of this lecture Assignment statements Expressions ASSIGNMENT STATEMENT Assignment Statements!!!mark = 50;!! Read as the value in variable on the LHS becomes equal
More informationProgramming Language Basics
Programming Language Basics Lecture Outline & Notes Overview 1. History & Background 2. Basic Program structure a. How an operating system runs a program i. Machine code ii. OS- specific commands to setup
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can
More informationChapter. Let's explore some other fundamental programming concepts
Data and Expressions 2 Chapter 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design 2007 Pearson Addison-Wesley. All rights reserved Data and Expressions Let's explore some
More information1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8
Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(
More informationWhat did we talk about last time? Examples switch statements
Week 4 - Friday What did we talk about last time? Examples switch statements History of computers Hardware Software development Basic Java syntax Output with System.out.print() Mechanical Calculation
More informationSECONDARY SCHOOL, L-IMRIEĦEL HALF YEARLY EXAMINATIONS 2016/2017
SECONDARY SCHOOL, L-IMRIEĦEL HALF YEARLY EXAMINATIONS 2016/2017 YEAR: 10 Computing Time: 1½ Hr. Name: Class: Instructions: 1. Answer all the questions in the space provided on this paper. 2. Calculators
More informationValues and Variables 1 / 30
Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides
More informationLogic Design: Part 2
Orange Coast College Business Division Computer Science Department CS 6- Computer Architecture Logic Design: Part 2 Where are we? Number systems Decimal Binary (and related Octal and Hexadecimal) Binary
More informationTopic 4 Expressions and variables
Topic 4 Expressions and variables "Once a person has understood the way variables are used in programming, he has understood the quintessence of programming." -Professor Edsger W. Dijkstra Based on slides
More informationChapter 2 Primitive Data Types and Operations. Objectives
Chapter 2 Primitive Data Types and Operations Prerequisites for Part I Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word Chapter 1 Introduction to Computers, Programs,
More informationObject-Oriented Programming
Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,
More informationCourse Outline. Introduction to java
Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.
More informationSection 2: Introduction to Java. Historical note
The only way to learn a new programming language is by writing programs in it. - B. Kernighan & D. Ritchie Section 2: Introduction to Java Objectives: Data Types Characters and Strings Operators and Precedence
More informationTester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time
Tester vs. Controller Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG For effective illustrations, code examples will mostly be written in the form of a tester
More informationINDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line
A SIMPLE JAVA PROGRAM Class Declaration The Main Line INDEX The Line Contains Three Keywords The Output Line COMMENTS Single Line Comment Multiline Comment Documentation Comment TYPE CASTING Implicit Type
More information