CSE 110 Quiz 1
What is the output of the following code snippet? public class PrintIt{ public static void main(String[] args){ System.out.println("4 * 4" + 12); } }
4 * 412
What is the output of the following code snippet? System.out.print(4 + 4); System.out.print(12);
812
When developing a program, the programmer adds the discount amount to the total instead of subtracting it. What type of an error is this?
A logic error
Which of the following statements is valid with respect to the usage of a semicolon in Java?
A semicolon is used to denote the end of a statement
What is the difference between an editor and a compiler?
An editor allows program files to be written and stored; a compiler converts program files into an executable program
An integrated development environment (IDE) bundles tools for programming into a unified application. What kinds of tools are usually included?
An editor and a compiler
What is a logic error?
An error that occurs when a program is running because, for example, the wrong operator was used
What kind of error is it when your program has a syntax error?
Compile-time error
Which of the following statements is true with respect to the main method in Java?
Every Java application must have a main method
What is the output of the following code snippet? System.out.print("Hello"); System.out.println("Good Day!");
HelloGood Day!
Consider the following statements about folders and your integrated development environment (IDE): I. Hierarchical folders help to organize a project II. Folders are a way to visualize the layout of a file system III. Folders make it impossible to lose or accidentally delete a file
I, II
Which option correctly completes this statement? Programs can repeat simple instructions very quickly to I. help human users to perceive images and sound II. remove the drudgery of repeating instructions by hand III. overcome the need for connectivity to the computer network
I, II
If you misspell a word in your Java program it may be true that I. the program will not compile II. the program may compile, but not run III. the program may compile and run but still have a logic error
I, II, III
What statements about the integrated development environment (IDE) are true? I. You may run Java class files even after exiting the IDE II. The IDE can invoke a virtual machine, which is required to run a Java program III. Translating Java source code into class files is enough to then actually run the program
I, II, III
Which of the following are reasons why Java is good, but not perfect, for beginners? I. A certain amount of technical machinery is necessary to write basic, simple programs II. There are many extensions III. There are a large number of extensive libraries in Java
I, II, III
Which statements are true? I. In Java, a file can contain at most one public class II. The word public denotes that the class is usable by the "public" III. Every Java program must have a main method
I, II, III
Which of the following statements regarding backup strategies for Java files are true? I. You should back up your projects often to prevent loss of valuable work II. You should check your backups only in case of loss of data III. You should pay attention to the backup direction
I, III
Which of these are true about writing algorithms in pseudo code? I. The exact wording is not important II. The sequence of steps should be ambiguous III. The algoirthm should terminate
I, III
Which pointers about backing up your Java projects are important? I. Check your backups once in a while II. Rely on the Java programming language's built-in back up system III. Back up often
I, III
Consider the following statements regarding computers: I. Computers can execute a large number of instructions in a fraction of a second. II. Computer application areas mainly target the research and scientific communities. III. The physical components of a computer constitute its hardware. IV. Unlike humans, a computer never gets bored or exhausted when performing repetitive tasks. Which are true?
I, III, IV
Which one of the following typically provides data persistence without electricity? I. The CPU's memory II. The hard disk III. Secondary storage
II, III
Consider the following statements about computer programs: I. Computer programs can be written by someone who has a basic knowledge of operating a computer. II. Computer programs can complete complex tasks quickly. III. Large and complex computer programs are generally written by a group of programmers. IV. Computer programs are composed of extremely primitive operations. Which are true?
II, III, IV
Java is said to be a "safe" programming language. What does this mean?
Java programs can run within a browser without fear that they may attack your computer
What kind of error is created by the following code snippet? System.out.print("The sum of 8 and 12 is "); System.out.println(8*12);
Logic error: the program does not produce the desired result
Suppose you examine a simple Java program and the first line is ' public Class HelloPrinter ' . Is this the same thing in Java as the line ' public Class helloprinter ' ?
No, because Java is case-sensitive, these are considered to be completely distinct
A Java class with the name Printer has to be saved using the source file name:
Printer.java
What is one of the benefits of using a high-level programming language like Java?
Problems solved in a high-level language are independent of the underlying computer
Who or what is responsible for inspecting and testing the program to guard against logic errors?
Programmer
Which one of the following methodologies is a sequence of steps formulated in English for solving a program?
Pseudocode
The programmer, not the compiler, is responsible for testing a program to identify
Run-time errors
Because Java was designed for the Internet, which two of its attributes make it suitable for beginning programmers?
Safety and portability
Which of the following refers to a collection of programs that a computer executes?
Software
What kind of error is created by the following code snippet? System.outt.println("Hello");
Syntax error: the program will not compile
Which one of the following errors represents a part of a program that is incorrect according to the rules of the programming language?
Syntax errors
Which one of the following code snippets compiles without errors and displays the output "Hello Good Day!" on the screen?
System.out.print("Hello "); System.out.println("Good Day!");
Which Java statement does not contain an error?
System.out.println();
Which Java statement prints a blank line?
System.out.println();
How do programmers find exceptions and run-time errors?
Testing by running the program with a variety of input values
Consider a scenario in which you develop a Java program on a computer that has a Pentium processor. What step should you take to run the same Java program on a computer that has a different processor?
The compiled Java machine language instructions can be run on any processor that has a Java Virtual Machine
When a compiler finds a syntax error in a program, what happens?
The compiler continues and may report about other errors but does not produce a Java class file
These two lines of code do not produce the same output. Why? System.out.println(7 + 3); System.out.println("7 + 3");
The quotes cause the second expression to be treated as a string
What is the output from this code snippet? System.out.print("The sum is "); System.out.println("7 + 3");
The sum is 7 + 3
A single silicon chip made from potentially millions of transistors is called
a Central Processing Unit (CPU)
The term "applet" refers to
a Java program that runs within a web browser
An example of an input device that interfaces between computers and humans is
a microphone
A Java Virtual Machine is
a program that simulates a real CPU
An example of an output device that interfaces between computers and humans is
a speaker
A sequence of steps that is unambiguous, executable, and terminating is called
an algorithm
Some run-time errors are so severe that they generate
an exception
Small applications written in the Java programming language that can be located on the Internet are called
applets
High-level programming languages
are independent of the underlying hardware
Every Java program consists of one or more
classes
In order for Java to achieve protability
compiled Java programs contain instructions for a virtual machine
In order to translate a Java program to a class file, the computer needs to have software called a(n)
compiler
Which one of the following translates high-level descriptions into machine code?
compiler
A Java "class" file
contains instructions to the Java virtual machine
The first step in describing an algorithm in pseudo code is
determine the inputs and outputs
Computers are machines that
execute programs
Computer scientists have devised something that allows programmers to describe tasks in words that are closer to the syntax of the problems being solved. This is called (an)
high-level programming language
Programs that are not running are usually stored
in secondary storage
In Java, the statement System.out.print("hello");;;
is a legal statement
Programmers have embraced Java over its closest rival, C++, mainly because
it is easier to use
When a program begins to run
it is moved to the CPU's memory
The Java programming language is itself relatively simple, but also contains a vast set of
library packages
The Java statement public static void main(String[] args) declares a
method
The ENIAC computer burned out transistors at the rate of
none -- it used vacuum tubes
The Central Processing Unit is primarily responsible for
performing program control and data processing
Which statement starts the declaration of a class in Java?
public class Classname
Which of the following statements must you include in a Java class that can be executed by the virtual machine?
public static void main(String[] args)
Writing a computer game in Java that has graphics, motion, and sound effects
requires a team of skilled programmers
Which of the following symbols is used to terminate a Java program statement?
semicolon
The technical term for the values that a method needs in order to carry out its task is an argument. When there is more than one argument needed by a method, they are
separated by commas
A Java virtual machine is
software
Characters that are grouped together between double quotes (quotation marks) in Java are called
strings
The source code for a Java program is stored in a file
that ends with a.java suffix
Computer programming is
the act of designing and implementing a computer program
Sometimes errors throw the compiler off track because
the compiler does not give up when it find the first error
Every statement in Java must be terminated with
the semi-colon character ;
During program development, errors are
unavoidable
The language developed by Sun Microsystems that became the Java programming language was originally designed to be simple, secure, and
usable for many different processor types
In order to run Java programs on a computer, the computer needs to have software called a(n)
virtual machine
In order for the ENIAC computer to be re-programmed
wires needed to be plugged into a different wiring configuration
In Java, if you want the compiler to interpret what you type as program instructions, you must
write correct Java statements separated by the semicolon