Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

Similar documents
CS111: PROGRAMMING LANGUAGE II

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

Review for Test 1 (Chapter 1-5)

PROGRAMMING FUNDAMENTALS

Introduction to Programming Using Java (98-388)

Final Exam. COMP Summer I June 26, points

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

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

Computer Programming, I. Laboratory Manual. Final Exam Solution

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

Motivation was to facilitate development of systems software, especially OS development.

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CS313D: ADVANCED PROGRAMMING LANGUAGE

Practice Midterm 1 Answer Key

2.8. Decision Making: Equality and Relational Operators

Java Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing

CSE 11 Midterm Fall 2008

1. [3 pts] What is your section number, the period your discussion meets, and the name of your discussion leader?

Computational Expression

Ryerson University Vers HAL6891A-05 School of Computer Science CPS109 Midterm Test Fall 05 page 1 of 6

Midterm Examination (MTA)

Iteration: Intro. Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times. 2. Posttest Condition follows body Iterates 1+ times

Name: Username: I. 20. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015

Practice Midterm 1. Problem Points Score TOTAL 50

Course Outline. Introduction to java

1. Short circuit AND (&&) = if first condition is false then the second is never evaluated

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

CSC 1214: Object-Oriented Programming

Selected Questions from by Nageshwara Rao

double d0, d1, d2, d3; double * dp = new double[4]; double da[4];

CSE 143 SAMPLE MIDTERM

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 8 October 2013 Midterm

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

Language Reference Manual

Final CSE 131B Spring 2004

Do not start the test until instructed to do so!

Java Bytecode (binary file)

COS 126 General Computer Science Spring Written Exam 1

CS251L REVIEW Derek Trumbo UNM

CS 139 Practice Midterm Questions #2

Problem Score Max Score 1 Syntax directed translation & type

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

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

COMSC-051 Java Programming Part 1. Part-Time Instructor: Joenil Mistal

JAVA Ch. 4. Variables and Constants Lawrenceville Press

CSCI 1226 Sample Midterm Exam

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

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

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

CS1004: Intro to CS in Java, Spring 2005

APCS Semester #1 Final Exam Practice Problems

The Java language has a wide variety of modifiers, including the following:

Motivation was to facilitate development of systems software, especially OS development.

Loops and Expression Types

CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:

Comp 170 Test 1 SAMPLE June 8, 2000

Introduction to Computer Science I Spring 2010 Sample mid-term exam Answer key

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Introduction to Java

COMP 202 Java in one week

CISC220 Lab 2: Due Wed, Sep 26 at Midnight (110 pts)

Lab5. Wooseok Kim

CHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS

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

ECE 2400 Computer Systems Programming Fall 2018 Topic 1: Introduction to C

Università degli Studi di Bologna Facoltà di Ingegneria. Principles, Models, and Applications for Distributed Systems M

1. What does the following code fragment write to the monitor?

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 24, Name: KEY 1

Java Fall 2018 Margaret Reid-Miller

Introduction to Programming (Java) 2/12

COMP-202: Foundations of Programming. Lecture 4: Flow Control Loops Sandeep Manjanna, Summer 2015

COMP 202. Java in one week

Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )

Problem Grade Total

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java Loop Control. Programming languages provide various control structures that allow for more complicated execution paths.

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Computer Science is...

Darrell Bethea May 25, 2011

Getting started with Java

Lecture Set 2: Starting Java

Java Primer 1: Types, Classes and Operators


CS 61C: Great Ideas in Computer Architecture Introduction to C

EECS1710. Checklist from last lecture (Sept 9, 2014) " get an EECS account (if you don t have it already) " read sections

Lecture Set 2: Starting Java

SAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

Question 1a) Trace of program

Quick Reference Guide

Discrete Structures Lecture 14

University of Massachusetts Amherst, Electrical and Computer Engineering

Creating a C++ Program

Java is an objet-oriented programming language providing features that support

1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005

Review of the syntax and use of Arduino functions, with special attention to the setup and loop functions.

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

CSI33 Data Structures

Transcription:

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, 2004 INSTRUCTOR: I E LEONARD TIME: 50 MINUTES In Questions 1 20, Circle EXACTLY ONE choice as the best answer 1 [2 pts] What company initially designed the Java programming language? (a) Microsoft (b) Sun (c) Intel (d) Oracle 2 [2 pts] What translates each line of source code into machine language and executes that line of code? (a) assembler (b) loader (c) compiler (d) interpreter 3 [2 pts] What set of rules determines whether or not a particular statement is correctly formulated? (a) semantic (b) syntactic (c) logical (d) precedence 4 [2 pts] What type of errors are detected by the Java compiler? (a) syntactic (b) semantic (c) logical (d) executable 5 [2 pts] What is a named memory location that can store a value of a particular type? (a) instance (b) object (c) class (d) variable

6 [2 pts] What is the extension used for the Java bytecode? (a) java (b) byte (c) class (d) app 7 [2 pts] What is a variable that is declared within a method called? (a) an instance variable (b) a class variable (c) a local variable (d) a static variable 8 [2 pts] What Java data type can have only two possible values? (a) button (b) boolean (c) byte (d) void 9 [2 pts] What type of access modifier is used to make a method accessible only within the class in which it is defined? (a) public (b) private (c) protected (d) prorated 10 [2 pts] In the following code fragment, what is displayed when issleeping is false and is Studying is true? if (issleeping) Systemoutprint(" Sleeping "); Systemoutprint(" Resting "); if (isstudying) Systemoutprint(" Studying "); (a) Sleeping (b) Resting (c) Studying (d) Resting Studying

11 [2 pts] In the following code fragment, what is displayed when iseating is true and isstudying is false? if (iseating) { if (isstudying) Systemoutprint(" Studying "); } else Systemoutprint(" Eating "); (a) Studying (b) Eating (c) Studying Eating (d) nothing is displayed 12 [2 pts] What keyword is used by an object to refer to itself? (a) abstract (b) extend (c) this (d) private 13 [2 pts] What data type is used to represent a real number? (a) short (b) double (c) byte (d) long 14 [2 pts] Which of the following declares a constant named RED? (a) public final RED = 0; (b) public static int RED; (c) public static final int RED = 0; (d) public final int RED = 0;

15 [2 pts] If a data type uses 4 bits in its representation, how many values can be represented? (a) 4 (b) 8 (c) 16 (d) 32 16 [2 pts] What operator has the highest precedence, that is, is evaluated first in an expression? (a) && (b) ( ) (c) (d)! 17 [2 pts] Which of the folowing for loop headers would be used to iterate from 10 down to 1? (a) for (int k = 1; k < 10; k++) (b) for (int k = 1; k < 10; k--) (c) for (int k = 10; k > 1; k--) (d) for (int k = 10; k > 0; k- -) 18 [2 pts] Which of the following loop headers would result in an infinite loop? (a) for (int k = 0; k > 10; k++) (b) for (int k = 0; k < 10; k- -) (c) for (int k = 0; k < 10; k++) (d) for (int k = 0; k > 0; k++) 19 [2 pts] Which loop structure does not contain syntax for the initializer and the updater? A (a) for (b) repeat (c) while (d) do while

20 [2 pts] In the code fragment below, what is the value of sum when the while loop terminates? int N = 12345; int n = N, sum = 0; while (n > 0) { sum = sum + n%10; n = n/10; } (a) 10 (b) 15 (c) 20 (d) 25 21 [2 pts] Perform the bitwise operation indicated below: 0 1 0 1 1 & 0 1 0 0 1 0 1 0 0 1 22 [2 pts] Perform the bitwise operation indicated below: 0 1 0 1 1 1 0 1 0 1 1 1 1 1 1

23 [2 pts] What is the output of the following code fragment? int limit = 1; Output: 1 for (int k = 1; k <= limit; k++) 2 { 3 Systemoutprintln(k); 4 limit++; 5 } 6 24 [2 pts] What is the output of the following code fragment? int limit = 0; Output: 0 for (int k = 0; k <= limit; k++) 0 { 0 Systemoutprintln(k); 0 k--; 0 } 25 [2 pts] Write a loop in JAVA which will display the cubes of the first 50 positive integers in decreasing order int limit = 50; for (int k = limit; k >= 1; k++) { Systemoutprintln(k*k*k); k--; }