CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck!

Similar documents
CSCE 145 Exam 1 Review Answers. This exam totals to 100 points. Follow the instructions. Good luck!

PROGRAMMING FUNDAMENTALS

final int a = 10; for(int i=0;i<a;i+=2) { for(int j=i;j<a;j++) { System.out.print("*"); } System.out.println(); }

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal

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

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2

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

Java 101 Build Season Code Standards. OCT

APCS Semester #1 Final Exam Practice Problems

CIS 110: Introduction to Computer Programming

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

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

Methods CSC 121 Spring 2017 Howard Rosenthal

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Methods CSC 121 Fall 2016 Howard Rosenthal

COMP 110 Introduction to Programming. What did we discuss?

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

Full file at

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b))

int x = 42, y = 33; //1 int z = x + y; //2 System.out.println(x + "+" + y + "=" + z); //3

Lecture Set 2: Starting Java

Lecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18

Lecture Set 2: Starting Java

Lecture Set 4: More About Methods and More About Operators

Lecture 6. Assignments. Summary - Variables. Summary Program Parts 1/29/18. Reading: 3.1, 3.2, 3.3, 3.4

Top-Down Program Development

Repe$$on CSC 121 Fall 2015 Howard Rosenthal

Basic Operations jgrasp debugger Writing Programs & Checkstyle

Question: Total Points: Score:

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 45 Obtained Marks:

Claremont McKenna College Computer Science

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Exam 2, Version 2. For the following code, mark True or False for statements 1.8 to 1.10.

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

CS 177 Week 15 Recitation Slides. Review

4. Java Project Design, Input Methods

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4

STUDENT LESSON A12 Iterations

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

Lecture Set 4: More About Methods and More About Operators

Repe$$on CSC 121 Spring 2017 Howard Rosenthal

Name: Checked: Preparation: Use variables to output a personalized message

Motivation of Loops. Loops. The for Loop (1) Learning Outcomes

Module 3 SELECTION STRUCTURES 2/15/19 CSE 1321 MODULE 3 1

Exam 1. CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey

Loops. EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG

Review for Test 1 (Chapter 1-5)

Mid Term Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Total Marks: 50 Obtained Marks:

What did we talk about last time? Examples switch statements

Computer Programming I - Unit 5 Lecture page 1 of 14

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009

Midterm Examination (MTA)

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

b. Suppose you enter input from the console, when you run the program. What is the output?

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

Control Statements Loops

CS 101 Fall 2006 Midterm 3 Name: ID:

Chapter 1. Introduction to Computers and Programming. M hiwa ahmad aziz

Last Class. While loops Infinite loops Loop counters Iterations

CIS 110 Introduction to Computer Programming Summer 2016 Midterm. Recitation # (e.g., 201):

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

Elementary Programming

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming

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

Control Structures: if and while A C S L E C T U R E 4

Introduction to Java Applications

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

Oct Decision Structures cont d

Practice Midterm 1 Answer Key

Motivation of Loops. Loops. The for Loop (1) Learning Outcomes

Loops. EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

Programming with Java

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

4. Assignment statements Give an assignment statement that sets the value of a variable called total to 20: Answer: total = 20;

So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees.

Introduction to Java & Fundamental Data Types

Fundamentals of Programming CS-110. Lecture 2

Supplementary Test 1

Chapter 2: Using Data

CS 1302 Chapter 9 (Review) Object & Classes

Introduction to Computer Science Unit 2. Notes

Final Exam. COMP Summer I June 26, points

Chapter 3. Selections

Mr. Monroe s Guide to Mastering Java Syntax

CSCE 121 ENGR 112 List of Topics for Exam 1

ESC101 : Fundamental of Computing

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination

Computer Programming, I. Laboratory Manual. Final Exam Solution

AP Computer Science A Unit 2. Exercises

CS 101 Spring 2007 Midterm 2 Name: ID:

Example Program. public class ComputeArea {

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

The LC3's micro-coded controller ("useq") is nothing more than a finite-state machine (FSM). It has these inputs:

Loops. CSE 114, Computer Science 1 Stony Brook University

Transcription:

CSCE 145 Exam 1 Review This exam totals to 100 points. Follow the instructions. Good luck! Chapter 1 This chapter was mostly terms so expect a fill in the blank style questions on definition. Remember look for those red, italics, bold, underlined words from the first slides. Here are some definitions that may be on the exam. 1. A is a digit with a value of either 0 or 1. 2. A consists of 8 bits. 3. Each byte in main memory resides at a numbered location called its. 4. A is a set of instructions for a computer to follow. 5. A translates a program from a high-level language to a low-level language the computer can run. 6. A is a library of classes that have been defined already. Such as import java.util.scanner; 7. A is used to store data such as number and characters, and has a type and a name associated with it. 8. Java translates a program into before compiling it to machine code. 9. A Java program typically consists of several pieces of code called. 10. An is a well defined set of instructions for solving a problem. 11. Algorithms usually are expressed in English or in. 12. The grammar rules for a programming language are called the of the language. 13. The three types of errors are,, and. 14. The place where the computer starts a running instructions is called the. In java it is //Starts here! 15. An instruction to the computer is called a, and it ends with a semicolon (;). 16. Java, C#, C++, Visual Basic, Python, Ruby are all examples of languages, which is easier to write and understand than machine code or assembly. Chapter 2 This chapter was solely on variables. You may expect terminology, short answer, and programming, but probably not all 3. Terminology Questions 1. When you a variable, you provide its name and type. 2. A is used for simple, non-decomposable values such as an individual number or individual character. Like (int, double, char)

3. A is used for a class of objects and has both data and methods. Like (String, Scanner, Random) 4. a variable is where you assign the variable a value before it is ever used. This is good programming practice as it doesn t rely on a default value. 5. An is a name, such as the name of a variable. 6. The equals sign (=) is called the. 7. Words such as if are called or and have special, predefined. 8. Uninitialized primitive variables may have a. Short Answer Questions These questions are more conceptual and could be true-orfalse questions with a short explanation, or write what the program snippet will print out. Also you can expect a question on the mod (%) operator. 1. Will this programming snippet give an error? True or False? If this does cause an error then why? String value1 = 34.0 ; int value2 = value1; 2. What will this program print out? int number = 20%7; System.out.println(number); Programming Questions These questions will be very similar to the lab assignments or the homework. 1. Write a program that prompts the user for a number which corresponds to degrees and change that number into radians. Then prints both the input and result. This conversion is rad = deg x 3.14159/180.0. Also assume that the input and the result are both double. import java.util.scanner;

Chapter 3 This chapter dealt with branch statements: if, else if, else, and switch. Not much terminology is here so there will be questions mainly on short answer and possibly programming. Expect a conversion from either switch to if, else if, else or the other way around. Short Answer Questions 1. When this program is executed what will it print out int number = 10; if(number < 5) System.out.println( A ); else if(number < 100 && number > 5) System.out.println( B ); else if (number < 20) System.out.println( C ); else System.out.println( D ); if(number > 1 number <=5) System.out.println( E ); else if(number > 2 && number <=40) System.out.println( F ); else System.out.println( G ); 2. Convert this if, else if, else into a switch statement if(n == 0) System.out.println( 0 ); else if(n == 1)

System.out.println( 1 ); else System.out.println(? ); Programming Questions If I do put one of these expect something along the same lines as labs, homeworks, or examples 1. Write a program where the user enters an integer and the program checks whether or not it is between 0 and 255 (both inclusive so it can be 0 and 255). If it is then the number is valid and the program will say that the number entered is valid. Otherwise it will prompt the user that they have entered an invalid number. import java.util.scanner;

Chapter 4 This chapter dealt with loops: while, for, and do while. This will mostly be short answer and programming. Short Answer Be able to explain the difference between do-while and while. Also be able to convert a for into a while and vice versa. Finally, be able to figure out what a loop prints out. 1. Explain the difference between a while and a do-while loop? The body of a do while will run at least once, and a while s body may never run at all. 2. Convert this for statement into a while statement for(int i=0;i<20;i++) System.out.print(i+ ); 3. What does the following program display? for(int i=0;i<10;i++) System.out.print(2*i+ ); Programming Questions Similar to the labs and examples. Also expect a question either on this exam or the final that has you print out something like the triangle from the lab assignment. 1. Write a program where the user enters a number, and the program prints out right triangle where the number is the width of the base. The triangle s base must be a the top and then go to the points. Example: If the user enters 5 the program will print out ***** **** *** **

* import java.util.scanner; 2. Write a program where the user enters a number, and then the program adds 10 from that number until the number is greater than 50. It must print out the new value at each step. Example if the user enters 14 the program will print out 14 24 34 44 import java.util.scanner;

Chapter 7 This chapter was on arrays, and will be mostly short answer and program questions. No sorting algorithms will be on this exam. 1. Write a program that finds the minimum and maximum number from an array and then subtracts the maximum from the minimum and prints the result out. The first line printed must be in the format, MAXIMUM-MINIMUM=RESULT Example if the array given was 10,4,6,8,2 the program would print out 10-2=8 int[] a = 10,4,6,8,2; 2. Write a program that multiplies all the number in an array and then prints out the result. Example if the array given is 2,4,6,8 the program would print 384 int[] a = 2,4,6,8;

3. Write a program that goes through an array and then changes every instance of an even number into a 0, and then prints out the resulting array. Example if the array given is 1,2,3,4,5,6,7,8 the program will print out 1 0 3 0 2 0 7 0 int[] a = 1,2,3,4,5,6,7,8; 4. Will this program cause an error? If so why does it cause an error? If not show what the program prints out? int[] a = 1,2,3,4,5; for(int i=0;i<=5;i++ System.out.println(a[i]);