CSC-151 Midterm Study Guide//Chapter 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

Java compiler translates Java source code into

Java bytecode

Can Java run on any machine? What is needed to run Java on a computer?

Java can run on any machine with a JVM.

Which of the following lines is not a Java comment? Please select all that apply.

-- comments; ** comments **

The extension name of a Java bytecode file is

.class

The extension name of a Java source code file is

.java

How is a java program executed?

A java program is executed from the main method in the class

String

A programming term meaning a sequence of characters. A string must be enclosed in double quotation marks.

Analyze the following code. I: public class Test { public static void main (String[] args) { System.out.println("Welcome to Java!"); } } II: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } }

Both I and II can compile and run and display Welcome to Java, but the code in I has a better style than II.

If a NoClassDefFoundError occurs when you run a program, what is the cause of the error?

Java interpreter cannot find the .class file. Make sure you placed the file in the right place, and invoked java command with appropriate package name.

________ is a technical definition of the language that includes the syntax and semantics of the Java programming language.

Java language specification

Is Java case sensitive? What is the case for Java keywords?

Java source code is case sensitive. Java keywords are always in lowercase.

_________ is a software that interprets Java bytecode.

Java virtual machine

Identify and fix the errors in the following code: public class Welcome { public void Main(String[] args) { System.out.println('Welcome to Java!'); } )

Line 2. Main should be main.Line 2. static is missing.Line 3: Welcome to Java! should be enclosed inside double quotation marks.Line 5: The last ) should be }.

Suppose you write a program for computing the perimeter of a rectangle and you mistakenly write your program so that it computes the area of a rectangle. What kind of error is this?

Logic error.

{}

Opening and closing braces, denote a block to enclose statments

If your program needs to read integers, but the user entered strings, an error would occur when ------ this program. What kind of error is this?

Runtime error.

If you forget to put a closing quotation mark on a string, what kind of error will be raised?

Syntax error (compile error)

What are syntax errors (compile errors), runtime errors, and logic errors?

Syntax errors are detected by compilers. Runtime errors occur during execution of the program. Logic errors results in incorrect results.

What is the statement to display a string on the console?

System.out.println(string);

Suppose you define a Java class as follows, the source code should be stored in a file named _________. public class Test {}

Test.java

If a NoSuchMethodError occurs when you run a program, what is the cause of the error?

The class does not have a main method, or the signature of the main method is incorrect.

What are the input and output of a Java compiler?

The input of a Java compiler is a Java source code file and the output is a Java class file.

What is the Java source filename extension, and what is the Java bytecode filename extension?

The source file extension is .java and the bytecode file extension is .class.

Every statement in Java ends with ________.

a semicolon (;)

Which JDK command is correct to run a Java application in ByteCode.class?

java ByteCode

What is the command to run a Java program?

java is the JDK command to run a program.

________ is a technical definition of the language that includes the syntax and semantics of the Java programming language.

java language specification

The JDK command to just compile a class (not run) in the file Test.java is

javac Test.java

What is the command to compile a Java program?

javac is the JDK command to compile a program.

If a program compiles fine, but it produces incorrect result, then the program suffers ________.

logic error

[]

opening and closing brackets, denote an array

()

opening and closing parentheses, used with methods

""

opening and closing quotation marks, enclose a string

What are examples of the reserved words?

public static void class

The main method header is written as:

public static void main(String[] args)

API

stands for Application Program Interface. It contains predefined classes and interfaces for developing Java programs.

IDE

stands for Integrated Development Environment. It is a tool that combines many functions into one program for quickly developing Java programs.

JDK

stands for Java Development Toolkit. It contains several separate programs for compiling, running, and testing Java programs.

JRE

stands for Java Runtime Environment. It is the program for running a Java program.

Statement terminator

the semicolon ; in java ends every statement

Keywords

words with specific meaning to the compile and cannot be used for other purposes in the program (i.e. class, static, and void)

What is the JVM?

JVM is the Java virtual machine that runs a Java program.

________ contains predefined classes and interfaces for developing Java programs.

Java API

________ provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface.

Java IDE

________ consists of a set of separate programs for developing and testing Java programs, each of which is invoked from a command line.

Java JDK

A Java application must have a main method.

True

Java is an object-oriented programming language.

True

The keywords in Java are all in lowercase.

True

True or False: Java is Architecture-Neutral.

True, meaning that the programs written on one platform can run on any other platform without having to rewrite or recompile them

A block is enclosed inside __________.

braces {}

//

double slashes, precede a comment line

Main method

entry point where the program begins execution

Programming style is important, because ______________.

good programming style makes a program more readable; good programming style helps reduce programming errors

syntax errors

if program violates a rule


Conjuntos de estudio relacionados

Chapter 3- Types of Policies and Riders

View Set

Exercise and Nutrition- train low and compete high, ketogenic diet, intermittent fasting

View Set

CSET Multiple Subjects: Subtest 2 - Math

View Set