Possible Exam Questions

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

Tools : The Java Compiler. The Java Interpreter. The Java Debugger

CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam

McGill University School of Computer Science COMP-202A Introduction to Computing 1

PROGRAMMING FUNDAMENTALS

SECONDARY SCHOOL, L-IMRIEĦEL HALF YEARLY EXAMINATIONS 2016/2017

JAVA Ch. 4. Variables and Constants Lawrenceville Press

Object-Oriented Programming

Chapter 2. Elementary Programming

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

Primitive Data, Variables, and Expressions; Simple Conditional Execution

Zheng-Liang Lu Java Programming 45 / 79

Course Outline. Introduction to java

Data Types and the while Statement

Darrell Bethea May 25, 2011

Pace University. Fundamental Concepts of CS121 1

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

CS 231 Data Structures and Algorithms, Fall 2016

Introduction to Java Applications

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

Simple Java Reference

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

( &% class MyClass { }

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Chapter 2: Basic Elements of Java

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

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

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

Lab 9: Creating a Reusable Class

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

CS 106 Introduction to Computer Science I

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

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.

1 Introduction Java, the beginning Java Virtual Machine A First Program BlueJ Raspberry Pi...

WOSO Source Code (Java)

Full file at

Chapter 2: Using Data

IT101. File Input and Output

F I N A L E X A M I N A T I O N

An overview of Java, Data types and variables

Accelerating Information Technology Innovation

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

CS 302: Introduction to Programming

Full file at

Chapter 2: Using Data

Java Bytecode (binary file)

CSc 2010 Principles of Computer Science, Fall 2013 Practice Problems for Midterm 3* * 3 17 % 9-20 % (26 / 7) "2"

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

CEN 414 Java Programming

1. An operation in which an overall value is computed incrementally, often using a loop.

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

Lab5. Wooseok Kim

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

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige

Variables, Types, Operations on Numbers

I/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O

13 th Windsor Regional Secondary School Computer Programming Competition

Programming with Java

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

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

University of Cape Town Department of Computer Science. Computer Science CSC115F. June Exam 2002

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

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. Chapter 1 Introduction to Computers, Programs, and Java

C++ Programming: From Problem Analysis to Program Design, Third Edition

Computer Science II (20082) Week 1: Review and Inheritance

IBPS Practice Exam 1. One megabyte equals approximately 1) 1,000 bits 2) 1,000 bytes 3) 1 million bytes 4) 1 million bits 5) 2,000 bytes 2.

St. Edmund Preparatory High School Brooklyn, NY

ECE 122. Engineering Problem Solving with Java

AP Programming - Chapter 6 Lecture

Crash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

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

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

Midterm Examination (MTA)

Chapter 1 Introduction to Java


false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

Full download all chapters instantly please go to Solutions Manual, Test Bank site: testbanklive.com

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

Elementary Programming

Chapter 02: Using Data

Classes Basic Overview

Introduction Unit 4: Input, output and exceptions

CMSC 331 Second Midterm Exam

VARIABLES, DATA TYPES,

Introduction to Programming Using Java (98-388)

Lecture Set 2: Starting Java

Values and Variables 1 / 30

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

Lab # 02. Basic Elements of C++ _ Part1

Syllabus for Computer Science General Part I

Chapters 1-4 Summary. Syntax - Java or C? Syntax - Java or C?

Lecture Set 2: Starting Java

Transcription:

Name: Class: Date: Here are all the questions from all your previous tests. Your exam will be made up of some of these questions. Use these to study from. Remember - all the answers are contained in your textbook. Possible Exam Questions True/False Indicate whether the sentence or statement is true or false. 1. An overflow error occurs when there are not enough bits to hold the mantissa. 2. Ergonomics is the science that studies copyright infringement. 3. The physical components of the computer are called software. 4. A multiuser OS allows for more than one user at the same time. 5. Cross-platform connectivity is the ability for one PC to use more than one input device. 6. WANs are used to connect devices over large geographical distances. 7. The largest and most widely accessed network is the Internet. 8. Outlook is an example of e-mail software. 9. A citation gives credit to the original author. 10. The illegal copying of software is called piracy. 11. The equal sign operator is used to assign a new value to a variable. 12. Values represented by the double data type are referred to as floating point. 13. The statement numplayers += 2; is the same as numplayers = numplayers + 2; 14. A run-time error is also called a syntax error. 15. The statement system.out.println("hello world!"); will generate a syntax error. 16. A run-time error halts program execution at the statement that cannot be executed. 17. The condition of an if statement is a Boolean expression. 18. A set of statements that perform a task over and over again based on a condition is called a loop structure. 19. Each execution of a loop is called an iteration. 20. The ++ operator is used in a for statement to automatically increment a counter by 2 during each loop iteration. 21. A method must include parameters. 22. Data passed to a method is called a parameter. 23. The return type void means that the method will return a value. 24. A method declaration contains the statements that implement the method. 25. Multiple parameters are separated by semicolons. 1

Name: 26. The order of the arguments passed to a procedure need to correspond to the order of the parameters declared in the procedure. 27. The number of arguments in a method call must match the number of parameters in the method declaration. 28. A method can return a value. 29. The return statement is used to send a value back to the calling statement. 30. Method overloading means that an application contains more than 10 methods. 31. Files are used to store the data generated by an application. 32. An exception is an error affecting execution. 33. The try statements are statements that could possibly generate an exception. 34. The file stream keeps track of the file position. 35. The end of file is indicated by 0. 36. A file on disk is a set of characters, even if the file contains numeric data. 37. Numeric data from a file must be converted to int or double values before it can processed. 38. A BufferedWriter class object is used to send text to the input file stream. 39. Writing objects to a file is called object deserialization. 40. The ObjectOutputStream class contains methods for writing primitive data types. Multiple Choice Identify the letter of the choice that best completes the statement or answers the question. 41. Which processes data and controls the flow of data between the computer s other units? a. CPU c. ROM b. USB d. SRAM 42. SRAM (Static Access RAM) is also referred to as a. ROM. c. cache. b. integrated circuits. d. clock rate. 43. Operating system software a. is a combination of hardware and software that works together to allow computers to exchange data. b. is network security hardware that prevents unauthorized network access. c. is software that enables the user to communicate with the computer. d. is a series of related web pages. 44. In which type of network topology is each node attached to a hub? a. bus topology c. ring topology b. star topology d. client topology 45. How many states do the electrical circuits on an IC (integrated circuit) have? a. one: on c. four: + - * / b. two: on, off d. three: on, off, wait 2

Name: 46. Which prevents unauthorized network access? a. a hub c. a firewall b. a router d. a cookie 47. An ISDN is a a. cable modem. c. subscriber line. b. conventional modem. d. digital telephone network. 48. Which programming language is considered a third generation programming language (3GL)? a. machine language c. SQL b. assembly language d. C 49. Which programming language is considered an object-oriented language? a. Fortran c. SQL b. Java d. C 50. Computer memory capacity and file size are measured in a. bytes. c. nanoseconds. b. inches. d. codes. 51. Which of the following represent correctly-formed comments? I. // Happy II. /* Sorry /* III. /* Wise */ a. I only c. I and III only b. I and II only d. III only 52. Which is a valid declaration statement? a. int height int width; c. int height; width; b. int height, width; d. int height, int width; 53. Which statement assigns the value 15 to radius? a. radius = 15; c. 15 = radius; b. radius == 15; d. 15radius; 54. What is the result of the following expression when x is 125? x%6 a. 0 c. 20 b. 5 d. 20.5 55. What happens to the decimal portion of a number when a double is cast to an int? a. The decimal portion is truncated. c. Nothing, a syntax error occurs. b. The decimal portion is rounded. d. The value 0.5 is added to the number. 56. Which type of error occurs in statements that are syntactically correct, but produce undesired or unexpected results? a. syntax error c. run-time error b. semantic error d. exception error 3

Name: 57. Which code segment displays the circle area when the radius is a positive value? a. if (radius!=0) { System.out.println("The area is: " + radius * radius * Math.PI); b. if (radius>=0) { System.out.println("The area is: " + radius * radius * Math.PI); c. if (radius>0) { System.out.println("The area is: " + radius * radius * Math.PI); d. if (radius==0) { System.out.println("The area is: " + radius * radius * Math.PI); 58. Which will be displayed when the code segment below is run? double grosspay = 4250.50; if (grosspay > 3000) { System.out.println("Your tax rate is 33%"); else if (grosspay > 4000) { System.out.println("Your tax rate is 35%"); a. Your tax rate is 33% b. Your tax rate is 35% c. Your tax rate is 33% Your tax rate is 35% d. A run-time error will be generated. 59. Given the following code segment: int x = 0; for (int i = 0; i < 8; i++) { x += i; System.out.println(x); Which will be displayed when the code segment is run? a. 7 c. 9 b. 8 d. 28 60. Given the following code segment: String lastname = "Watson"; int namelength; namelength = lastname.length(); What is the value of namelength after the statements execute? a. 5 c. 8 b. 6 d. Watson 4

Name: 61. A problem-solving approach that breaks tasks into smaller subtasks is called a. bottom-up development. c. top-down development. b. task division development. d. procedural development. 62. A method is executed when it is a. typed. c. declared. b. called. d. named. 63. Which keyword is an access modifier? a. static c. public b. void d. call 64. Which statement calls the method inchestocentimeters()? a. call inchestocentimeters; b. inchestocentimeters(call); c. inchestocentimeters(); d. execute inchestocentimeters(); 65. How many arguments are passed in the statement checkguess(i, valitem)? a. 1 c. 3 b. 2 d. 4 66. How many parameters are declared in the statement public static void checkguess(int length, int width)? a. 1 c. 3 b. 2 d. 4 67. (Application) Given the following code segment: public static void prob(int x, int y) { System.out.print(x + " "); if (x <= y) { System.out.println(x + y); Which will be displayed when prob(6, 7) is called? a. 6 7 c. x + 7 b. x + 6 d. 6 13 68. The arguments in a method call must a. correspond in order to the parameters in the method being called. b. have the same names as the corresponding parameters in the method being called. c. be variables. d. be integers. 69. When more than one method of the same name is included in a class, it is referred to as method a. passing. c. overloading. b. duplicating. d. voiding. 5

Name: 70. (Application) Given the following application: public class Calculation { public static int linelength(int x, int y) { int length; length = x * y; return length; public static int linelength(int x) { int length; length = x * x; return length; public static void main(string[] args) { System.out.println(lineLength(5)); Which will be displayed when the application is run? a. 5 c. 25 b. 10 d. A syntax error will be generated. 71. (Application) Given the following application: public class Comparison { public static double maxnum(int num1, int num2) { if (num1 > num2) { return num1; else { return (num2); public static double maxnum(int value1, int value2) { if (value1 > value2) { return value1; else { return (value2); public static void main(string[] args) { System.out.println(maxNum(1, 2)); Which will be displayed when the application is run? a. 1 c. 2.0 b. 2 d. A syntax error will be generated. 6

Name: 72. (Application) Given the following code segment: public static int prob2(int x, int y) { y += x * 2; return(y); public static void main(string[] args) { int j = 6, k = 4; j = prob2(j, k); System.out.println(j); Which will be displayed after the code executes? a. 4 6 c. 16 b. 12 d. 20 73. How many values can a return statement return? a. 0 c. 3 b. 1 d. An unlimited number. 74. A statement of what must be true at the end of the execution of a procedure is called a(n) a. precondition. c. ending comment. b. postcondition. d. procedure condition. 75. Which statement is required to access the File class? a. import java.io.* c. import java.awt.* b. import java.util.* d. import java.lang.* 76. Which is the error in the statement, File textfile = new File("c:\MyDocuments\data.txt");? a. The file path does not have to be in quotes ("). b. The words new File are not necessary. c. Escape sequences need to separate the drive, folder, and file names (\\). d. There is no error in the statement. 77. Which is a block of code that performs an action when an exception occurs? a. throw stream c. exception handler b. err stream d. action handler 7

Name: 78. Given the following code segment: File textfile = new File("c:\\inventory.txt"); if (textfile.exists()) { System.out.println("The file already exists."); else { try { textfile.createnewfile(); System.out.println("The file was created."); catch (IOException e) { System.out.println("The file could not be created."); System.err.println("IOException: " + e.getmessage()); Which is the statement that could possibly generate an exception in the try-catch-finally statement? a. textfile.exists() b. System.err.println("IOException: " + e.getmessage()); c. IOException d. textfile.createnewfile(); 79. Which class is used to create an input file stream? a. BufferedReader c. FileWriter b. FileReader d. BufferedWriter 80. Which class is used to create an output file stream? a. BufferedReader c. FileWriter b. FileReader d. BufferedWriter 81. Given the following statement: File datafile = new File("inventory.dat"); Which will occur if there is an existing inventory.dat file? a. An IOException will be thrown. b. An inventory1.dat file will be created. c. The existing file will automatically be overwritten. d. A prompt will appear asking if the file should be overwritten. 82. Given the following statement: File datafile = new File("inventory.dat"); Which will occur if inventory.data does not exist? a. An IOException will be thrown. b. A new inventory.dat file will be created. c. The existing file will automatically be overwritten. d. A prompt will appear asking if the file should be overwritten. Completion Complete each sentence or statement. 83. Errors that violate the rules of Java are called errors. 8

Name: 84. A is a collection of related data stored on a persistent medium. 85. File streams are used to perform file access, with all the reading and writing performed one character after another or one line after another. Short Answer 86. (1 mark) What does HTML stand for? 87. (1 mark) What does CSS stand for? 88. (4 marks) List some rules typically found on an Acceptable Use Policy. 89. (5 marks Application) Sketch a flowchart for the following program description: The Information application displays your name on a separate line, your school on a separate line, and your current school classes on the same line, separated by a tab. 90. (5 marks Application) Identify five errors in the following application: /* * InternetRules.java /* package studentrules /** * Displays student rules for accessing the Internet. */ public class InternetRules public static void main(string[] args) { System.out.println("Internet Rules\n"); System.out.println("1. Use school issued login and password."); System.out.println("2. Do not download any files.") system.out.println("3. Do not reveal personal information."); 91. (2 Marks - Communication) Write an appropriate decision statement to display You move to the next level. when the value of points is 150 or higher. 92. (8 marks - communication) Complete the following: a) Write an algorithm for obtaining a gross pay amount from the user and then determining an appropriate tax bracket amount based on the gross pay entered. If the gross pay is less than $700, the tax rate is 26%, if the gross pay is between $700 and $1,200 inclusive, the tax rate is 33%, and if the gross pay is greater than $1,200, the tax rate is 36%. b) Write the pseudocode for the algorithm developed in part (a). 93. (Communication 4 marks)list two naming conventions for method names. 9

Name: 94. (Application) (2 marks)write a statement to call a method named checkvalue() that has two int parameters named firstnum and secondnum. 95. (Communication 6 marks) Write the method declaration for a public class method named calculateaverage() that has double parameters firstnum, secondnum, thirdnum and returns a double value. 96. (Application) (4 marks) Write a productinventory() method that calculates the total number of products available in four store locations and returns the total. The productinventory() method should contain int store1, store2, store3, and store4 parameters and return an int value. 97. (2 marks Application) List two examples of a persistent medium. 98. (2 marks Communication & Application) Explain why should an exception handler should be used in an application? 99. (2 marks Communication & Application) Explain how the FileReader and BufferedReader classes work together to read the contents of an existing file? Essay 100. (4 MARKS) Describe the ethical and system reliability responsibilities associated with being an IT professional. 10