Programming Exam 1

Ace your homework & exams now with Quizwiz!

A run-time error

(logic error) causes a program to perform an action that the programmer did not intend.

A compiler-time error

(syntax error) is a violation of the programming language rules detected by the compiler

When was Java officially introduced?

1995

In Java, every statement must end with the symbol

;

Which of the following statements about methods is correct? a) a method is a sequence of instructions that could access the data of an object b) a method name is unique across the entire program c) a method can be called on any object in any class d) methods are stored in variables

A

Assuming the following Java statement: Circle c1 = new Circle(3); What does the variable c1 store?

A reference to the memory location of the constructed Circle object

Pseudocode

An informal description of of a sequence of steps for solving a problem

What does API stand for?

Application Programming Interface

How do you modify the HelloPrinter program to greet you instead?

Change World to your name (here, Dave):

Which statement about identifiers is correct? a) identifiers are not case sensitive b) identifiers can use symbols such as ? or % c) spaces are permitted inside identifiers d) identifiers can be made up of letters, digits, and the underscore (__) character

D

Where is a program stored when it is not currently running?

In secondary storage, typically a hard disk.

How long does it take to learn the entire Java library?

No one person can learn the entire library - it is too large.

In Java, objects are grouped into classes according to their behavior. Would a window object and a water heater object belong to the same class or to different classes? Why?

Objects with the same behavior belong to the same class. A window lets in light while protecting a room from the outside wind and heat or cold. A water heater has completely different behavior. It heats water. They belong to different classes.

A ________________ is a collection of classes with a related purpose

Package

What are the two most important benefits of the Java language?

Safety and portability

Which of the following statements about test programs is true? a) Test programs verify that methods have been implemented correctly. A test program calls methods and checks that they return the expected results b) a test class does not contain the main method c) you do not have to display the expected results d) writing test programs is not an important skill

Test programs verify that methods have been implemented correctly. A test program calls methods and checks that they return the expected results

Where is the HelloPrinter.java file stored on your computer?

The answer varies among systems. A typical answer: • /home/dave/cs1/hello/HelloPrinter.java or • c:\Users\Dave\Workspace\hello\HelloPrinter.java

Which part of the computer carries out arithmetic operations, such as addition and multiplication?

The central processing unit

Suppose you change println to printline in the HelloPrinter.java program. Is this a compile-time error or a run-time error?

This is a compile-time error. The compiler will complain that System.out does not have a method called printline.

Suppose you omit the "" characters around Hello, World! from the HelloPrinter.java program. Is this a compile-time error or a run-time error?

This is a compile-time error. The compiler will complain that it does not know the meanings of the words Hello and World.

Some light bulbs use a glowing filament, others use a fluorescent gas. If you consider a light bulb a Java object with an "illuminate" method, would you need to know which kind of bulb it is?

When one calls a method, one is not concerned with how it does its job. As long as a light bulb illuminates a room, it doesn't matter to the occupant how the photons are produced.

What is the Java Virtual Machine?

a

What is the name of the file that contains the Java source code for the public class

a

No matter which Java development environment you use, what happens to the Java source code in order for a Java program to execute?

a Java compiler translates the source code into class files

What is an editor?

a program for entering and modifying text, such as a Java program

Input to a method, enclosed in parenthesis after the method name, is known as

arguments

Every Java program consists of one or more of these fundamental building blocks

class

What tool translates high-level instructions into low level machine code?

compiler

What declares a variable that will store a measurement with fractional parts?

double measure;

What term is used to refer to languages that allow programmers to describe tasks at a higher conceptual level than machine code?

high-level

To use a class in another package you need to ____________ it

import

Which import statement allows for statement allows for the use of the rectangle class? import java.geom.Rectangle2D import java.geom.RectangularShape; import java.geom.Rectangle; import java.awt.Rectangle;

import java.awt.Rectangle;

What is the name of the type that denotes whole numbers?

int

Which package is automatically imported in any Java program? java.system java.lang java.language java.util

java.lang

By convention among Java programmers, variables begin with a

lowercase letter

A ____________ contains sequence of programming instructions that describe how to perform a particular task

method

consists of a sequence of instructions that can access the data of an object

method

What does a computer user need to know about programming in order to play a video game?

nothing

An entity in your program that you can manipulate by calling one or more of its methods

object

Which of the following terms denotes the memory location of an object?

object reference

The building blocks that Java programmers use to write computer programs are called _________

objects

What term is used to refer to an individual instruction inside a method

statement

Assuming the following Java statement: int num =10; What does the variable num store?

the numeric value 10

What is the purpose of the assignment operator?

to change the value of a variable

By convention among Java programmers, class names begin with an

uppercase letter

Use a __________ to store a value that you want to use later

variable

What is a storage location in the computer's memory called that has a type, name, and contents?

variable

What do you do to protect yourself from data loss when you work on programming projects?

you back up your files and programs


Related study sets

Elasticity- price elasticity of demand

View Set

Clinical presentation & Diagnosis/Disease

View Set

Microbiology An Introduction Chapter 2

View Set

What is the best definition of species?

View Set

Section 9, Unit 3: Qualifying the Collateral

View Set

4 Lists, Stacks, and Queues, data structures

View Set