OWEN COMPUTER SCIENCE LESSONS L2RVW4 Pg 1. Lesson 2 Review #4. Matching. Match each description to the correct data type.

Similar documents
Java Module Lesson 2A Practice Exercise

Exercise: Using Numbers

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

Java Simple Data Types

PROGRAMMING FUNDAMENTALS

Key Java Simple Data Types

Lesson 2A Data. Data Types, Variables, Constants, Naming Rules, Limits. A Lesson in Java Programming

An Introduction to Processing

Java Simple Data Types

A+ Computer Science VARIABLES. A+ Computer Science -

Data types Expressions Variables Assignment. COMP1400 Week 2

JAVA OPERATORS GENERAL

1. What is the minimum number of bits needed to store a single piece of data representing: a. An integer between 0 and 100?

Tasks for fmri-setting (Tasks of first and second pilot study at the end)

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Computational Expression

Prof. Navrati Saxena TA: Rochak Sachan

Reserved Words and Identifiers

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Main Memory Organization

Ex: If you use a program to record sales, you will want to remember data:

Primitive Types. Four integer types: Two floating-point types: One character type: One boolean type: byte short int (most common) long

Chapter 2: Using Data

Midterm Examination (MTA)

CS313D: ADVANCED PROGRAMMING LANGUAGE

Chapter 2: Introduction to C++

REVIEW. The C++ Programming Language. CS 151 Review #2

Understand Computer Storage and Data Types

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Database Programming with PL/SQL

ESc101 : Fundamental of Computing

Chapter 2: Basic Elements of Java

JAVA WRAPPER CLASSES

Basic Operations jgrasp debugger Writing Programs & Checkstyle

DEPARTMENT OF MATHS, MJ COLLEGE

COMP Primitive and Class Types. Yi Hong May 14, 2015

3. Java - Language Constructs I

1.3b Type Conversion

Computer Components. Software{ User Programs. Operating System. Hardware

Values, Variables, Types & Arithmetic Expressions. Agenda

The C++ Language. Arizona State University 1

Full file at

Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi Section Webpage:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

CIS 110: Introduction to Computer Programming

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

CHAPTER 3 BASIC INSTRUCTION OF C++

Lecture 2. Examples of Software. Programming and Data Structure. Programming Languages. Operating Systems. Sudeshna Sarkar

2. Numbers In, Numbers Out

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

CS 106 Introduction to Computer Science I

Computer Programming : C++

(Refer Slide Time: 00:23)

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number:

Datatypes, Variables, and Operations

Introduction to Object-Oriented Programming

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Chapter 3: Operators, Expressions and Type Conversion

Chapter 6 Primitive types

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

Accelerating Information Technology Innovation

Review for Test 1 (Chapter 1-5)

VARIABLES AND TYPES CITS1001

Control Structures in Java if-else and switch

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

More Programming Constructs -- Introduction

Section 2.2 Your First Program in Java: Printing a Line of Text

ECE 122 Engineering Problem Solving with Java

Computer Components. Software{ User Programs. Operating System. Hardware

Basic data types. Building blocks of computation

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Java Fall 2018 Margaret Reid-Miller

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Chapter 5 Control Statements: Part 2 Section 5.2 Essentials of Counter-Controlled Repetition

AP Computer Science Homework Set 1 Fundamentals

1 class Lecture2 { 2 3 "Elementray Programming" / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch.


BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 4 Certificate in IT SOFTWARE DEVELOPMENT

C/C++ Programming for Engineers: Working with Integer Variables

More on methods and variables. Fundamentals of Computer Science Keith Vertanen

Exam 1. CSC 121 Spring Lecturer: Howard Rosenthal. March 1, 2017

Basics of Java Programming

BRANCHING if-else statements

2. Numbers In, Numbers Out

Test 1. CSC 121 Lecture Lecturer: Howard Rosenthal. March 4, 2014

Strings. Strings and their methods. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

CSc Introduction to Computing

LECTURE 3 C++ Basics Part 2

Eng. Mohammed S. Abdualal

Lecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos.

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double

M1-R4: Programing and Problem Solving using C (JULY 2018)

Chapter 1 INTRODUCTION

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School

BITG 1233: Introduction to C++

Software Practice 1 Basic Grammar

Classwork. Exercises Use long division to determine the decimal expansion of. NYS COMMON CORE MATHEMATICS CURRICULUM Lesson 6 8 7

Chapter 2: Using Data

Getting started with Java

Chapter-8 DATA TYPES. Introduction. Variable:

Transcription:

OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 1 Lesson 2 Review #4 Name Matching Match each description to the correct data type. a. int e. short b. float f. long c. double g. char d. byte 1. up to 15 decimal places of storage and output precision 2. -32768...32767 3. -2147483648...2147483647 4. 0...65535 5. up to 7 decimal places of storage and output precision 6. -128...127 7. approximately -9 quintillion...9 quintillion Complete each sentence or statement. 8. Classify this statement as valid or invalid. final int x = 5; x = 6; 9. For what two word phrase is bit an abbreviation? 10. The function of the assignment operator (=) is a to process. 11. The term _ indicates that an operator performs a process of some sort on two values or objects. 12. Complete the statement. A Java constant is usually all letters. 13. Indicate the correct value in bits for memory storage for the data type listed. char ==> bits 14. Fill in the blank with the appropriate data type (int, double, String, char, boolean). d = -14.5; 15. What Java limit does this value represent? -9223372036854775808. VALUE 16. Classify this identifier as valid or invalid for use in Java. 8ball

OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 2 17. Classify this statement as valid or invalid. final String n = "Z" 18. Classify this identifier as valid or invalid for use in Java. miles_per_hour 19. Indicate the correct value in bits for memory storage for the data type listed. int ==> bits 20. What is the output of this statement? byte b = -128; b = b-1; System.out.println(b); 21. Fill in the blank with the appropriate data type (int, double, String, char, boolean). hungry = true; 22. What Java limit does this value represent? 127. VALUE 23. What is the operator that checks to see if two pieces of data are equal? Fill in the blanks with the correct output produced by the code segments shown below, as if they were sequential statements all part of the same program. 24. int num1 = 49; int num2 = 7; 25. num1 = -35; num2 = 6; 26. num1 = 24; num2 = -3; 27. num1 = 41; num2 = 3;

OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 3 28. num1 = 93; num2 = 3; 29. num1 = 16; num2 = 5; 30. num1 = 10; num2 = -1; Fill in the blanks with the correct output produced by the code segments shown below as if they were sequential statements all part of the same program. It is possible that not all of the blanks will be used each time. 31. int x = 1; while(x<6) x++; 32. x = 10; while(x>0) x--; 33. x = 4; while(x<20) x+=3;

OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 4 34. x = 30; while(x>=0) x-=5; 35. x = 2; while(x<100) x*=3; 36. x = 100; while(x>0) x/=3; Fill in the blanks with the correct output produced by the code segments shown below, as if they were sequential statements all part of the same program. 37. double dub1 = 24.6; double dub2 = 8.2; System.out.printf("%.1f / %.1f = %.1f\n",dub1,dub2,dub1 / dub2); 38. System.out.printf("%.1f %% %.1f = %.1f\n",dub1,dub2,dub1 % dub2); 39. dub2 = 16.4; System.out.printf("%.1f / %.1f = %.1f\n",dub1,dub2,dub1 / dub2); 40. System.out.printf("%.1f %% %.1f = %.1f\n",dub1,dub2,dub1 % dub2);

OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 5 41. dub1*=-1; System.out.printf("%.1f / %.1f = %.1f\n",dub1,dub2,dub1 / dub2); 42. System.out.printf("%.1f / %.1f = %.1f\n",dub1,dub2,dub1 / dub2); 43. dub1*=-1; dub2*=-1; System.out.printf("%.1f / %.1f = %.1f\n",dub1,dub2,dub1 / dub2); 44. System.out.printf("%.1f %% %.1f = %.1f\n",dub1,dub2,dub1 % dub2); Fill in the blanks with the correct output produced by the code segments shown below, as if they were sequential statements all part of the same program. 45. int num1 = 4; int num2 = 5; System.out.printf("%d / %d = %d\n",num1,num2,num1 / num2); 46. System.out.printf("%d %% %d = %d\n",num1,num2,num1 % num2); 47. num2 = 3; System.out.printf("%d / %d = %d\n",num1,num2,num1 / num2); 48. System.out.printf("%d %% %d = %d\n",num1,num2,num1 % num2); Fill in the blanks with the correct output produced by the code segments shown below as if they were sequential statements all part of the same program. 49. int num = 5; double dub = 2.5; char let = 'E'; System.out.printf("%d %.1f %s\n",num,dub,let); 50. num += 4.6; dub *= 3.8; let += 33; System.out.printf("%d %.1f %s\n",num,dub,let);

OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 6 51. num *= 2.4; dub /= 3.6; let -= 20.3; System.out.printf("%d %.1f %s\n",num,dub,let); 52. num -= '1'; dub += 40; let += 33.5; System.out.printf("%d %.1f %s\n",num,dub,let);

OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 7 Lesson 2 Review #4 Answer Section MATCHING 1. ANS: C 2. ANS: E 3. ANS: A 4. ANS: G 5. ANS: B 6. ANS: D 7. ANS: F 8. ANS: invalid 9. ANS: binary digit 10. ANS: right to left 11. ANS: binary 12. ANS: capital 13. ANS: 16 14. ANS: double 15. ANS: Long.MIN_VALUE 16. ANS: invalid 17. ANS: valid 18. ANS: valid 19. ANS: 32 20. ANS: 127 21. ANS: boolean 22. ANS: Byte.MAX_VALUE 23. ANS: == 24. ANS: 49 divisible by 7: true 25. ANS: -35 divisible by 6: false 26. ANS: 24 divisible by -3: true 27. ANS: 41 divisible by 3: false 28. ANS: 93 divisible by 3: true 29. ANS: 16 divisible by 5: false 30. ANS: 10 divisible by -1: true 31. ANS: 1 2 3 4 5 32. ANS: 10 9 8 7 6 5 4 3 2 1 33. ANS: 4 7 10 13 16 19 34. ANS: 30 25 20 15 10 5 0 35. ANS: 2 6 18 54 36. ANS: 100 33 11 3 1 37. ANS: 24.6 / 8.2 = 3.0

OWEN COMPUTER SCIENCE LESSONS 2014-2015 L2RVW4 Pg 8 38. ANS: 24.6 % 8.2 = 0.0 39. ANS: 24.6 / 16.4 = 1.5 40. ANS: 24.6 % 16.4 = 8.2 41. ANS: -24.6 / 16.4 = -1.5 42. ANS: -24.6 % 16.4 = -8.2 43. ANS: 24.6 / -16.4 = -1.5 44. ANS: 24.6 % -16.4 = 8.2 45. ANS: 4 / 5 = 0 46. ANS: 4 / 5 = 4 47. ANS: 4 / 3 = 1 48. ANS: 4 % 3 = 1 49. ANS: 5 2.5 E 50. ANS: 9 9.5 f 51. ANS: 21 2.6 Q 52. ANS: -28 42.6 r