Module 4 Flashcards

1
Q

Which of the following are true regarding the Java method main?

A) In the declaration of main, the term “public” means that the main method is available from anywhere within the program.
B) The method main is called by the Java Virtual Machine when the program is started.
C) The method main is called by the Java compiler.
D) In the declaration of main, the term “static” means that the main method exists in memory and can be executed without creating an object.

A

B) D)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following is a valid method header for the “main” method required in each Java application?

A) public static void main (String args)
B) public static int main (String [] args)
C) private static void main(String [] args)
D) public void main (Strings [] args)
E) public static void main ( String [] args)

A

E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following languages is interpretive?

A) BASIC
B) GRASP
C) C++
D) Java

A

A)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following are primitive Java data types?

A) double
B) String
C) array
D) int
E) integer

A

A) D)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Please select all of the following statements which apply to the Eclipse Integrated Development Environment (IDE).

A) Eclipse must be used to develop and run Java programs.
B) Eclipse replaces the Java Virtual Machine.
C) Eclipse is one of many IDEs which may be installed to use the Java language software.
D) The Eclipse IDE facilitates the development of Java programs.
E) Eclipse should be installed on your system after the installation of the Java language system if you are going to use Eclipse for your IDE.

A

C) D) E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following are true about Java string literals?

A) A Java string literal is delimited by single quotes
B) The value of a Java string literal can change
C) When a Java string literal appears within the parenthesis of a println statement it will print out exactly as it appears
D) A Java string literal can contain letters of the alphabet and the digits 0 through 9

A

C) D)

Java string literals are constants delimited by double quotes. They can contain letters and digits and can be used to describe a string to be printed by the println method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following are true regarding the general description of keywords in a computer language?

A) A particular keyword is used only in particular ways in a language.
B) A particular keyword has one or more specialized meanings in the language.
C) Keywords in a language must be recognizable words in a written language.
D) The meaning of a keyword is determined by the context in which it is used in a program.
E) A particular keyword has the same meaning as its equivalent English word.

A

A) B) D)

Keywords do not have to mimic English words or words in any other language. All other answers are correct.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the following statements are true?

A) Java objects are created at execution (run) time
B) Java objects are created by declaration statements that include the class name and object name
C) Java objects are created by the new operator
D) Java objects are created by a class declaration in the source file
E) Java objects are created by the compiler when you compile your source code

A

A) C)

Classes are templates or descriptions of objects. The actual object is created at run time by use of the new operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The Java SE language system consists of which of the following?

A) a compiler
B) an interpreter
C) a debugger
D) a runtime environment
E) a text editor

A

A) D)

The Java SE (standard edition) language system consists of two main parts, its compiler, which is known as javac And a run-time environment know as the JRE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following Java statements correctly declares a constant?

A) double mORTGAGE_RATE = 3.5;
B) constant mRATE = 3.5;
C) final double MRATE = 3.5;
D) constant MORTGAGE_RATE = 3.5;

A

C)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which of the following are characteristics of an algorithm?

A) Creating an algorithm is usually a trivial task
B) A computer program constitues an algorithm
C) Algorithms can assume certain input
D) The steps of an algorithm must be performed in a particular order
E) An algorithm is a sequence of instructions

A

B) D) E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which of the following are true about the Java statement public static void main (String[] args)?

A) It is a class header
B) It is always required in a Java application program
C) You can leave out the word “static” if you like
D) The word “main” is user defined, you can call it anything you like
E) It is a method header

A

B) E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The programming process in Java includes which of the following activities?

A) Writing machine code
B) Determining what the program is supposed to accomplish
C) Developing invalid input as test data
D) Resolving all program logic errors
E) Determining program output display

A

B) C) D) E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of the following are true about logic errors?

A) Logic errors potentially result in incorrect program output
B) Logic errors are detected by the compiler
C) Logic errors must be fixed before testing
D) Logic errors are detected at runtime
E) Logic errors are detected by analyzing the operation of a program

A

A) D) E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which of the following are valid Java variable names?

A) hourly_wage
B) 4tree
C) pay rate
D) Course$Grade
E) house

A

A) D) E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In Java, what does the statement c += a mean?

A) c + 1 = a
B) none of these answers are correct
C) c = a + 1
D) c + c = a
E) c = c + a

A

E)

17
Q

Which of the following are true about a software program?

A) A program is responsible for validating user inputs
B) A program consists of instructions that can be executed in any order.
C) A program consists of instructions that must be executed in a particular sequence
D) A program consists of instructions that accomplish a specific operation
E) A set of program instructions is known as an algorithm

A

A) C) D) E)

A program consists of instructions that have speci”c functions and must be executed in a particular sequence or order. These instructions are collectively known as an algorithm.

18
Q

Which of the following are true regarding Java syntax?

A) indentation is important to Java
B) Curly braces, { }, always exist in pairs
C) a comment starts with “\”
D) blank lines are ok
E) a single java statement cannot occupy more than one line

A

B) D)

Blank lines are ok and curly braces must occur in pairs. A Java statement can be split across lines. Comments start with //. Indentation is used strictly to make a program more readable and is ignored by the compiler.

19
Q

Which of the following statements are true about Java?

A) The Java compiler generates machine code
B) Java was developed at IBM
C) Java does not support objects
D) A Java program runs on a Java Virtual Machine
E) Java was developed for embedded applications

A

D) E)

20
Q

If c equals negative two, what does an equal in the following Java statement?
a = 2 + c++

A) 0
B) 1
C) 2
D) 6
E) -2

A

A)

21
Q

In Java, the expression 5 -10 – 5/2 evaluates to

a. -5
b. -6
c. -7
d. -8

A

C)

In Java, constants such as these are stored in integer format, hence 5/2 will be done using integer arithmetic. So 5/2 evaluates to 2, and then 5 – 10 – 2 from left to right evaluates to -5 – 2, which is -7. If any of the numbers had been expressed with a decimal point, such as 5.0/2, then 5.0 would have been stored as a floating point number and floating point division would be done yielding 2.5.

22
Q

Which of the following statements are true regarding an Interactive Development Environment (IDE)?

A) An IDE generates algorithms for the programmer.
B) An IDE expedites the resolution of runtime problems.
C) An IDE contains access to an editor and a compiler so that the programmer can cycle through these steps iteratively and easily before proceeding outside to the runtime environment.
D) An IDE is a burden to programmers, but produces faster code.

A

B)

An IDE contains access to an editor, a language compiler AND a runtime environment, which simplifies the development environment. It also provides easy access to debugging information which programmers can signal it to use. This expedites the resolution of runtime problems.

23
Q

What is a void method in Java?

A) One that requires no static memory
B) One that requires no inputs
C) One that is called “main”
D) One that returns no data

A

D)

A void method is one that returns no data. “main” is defined as a void method, but that is not the definition of the term.

24
Q

What does a Java compiler generate?

A) object code
B) machine language
C) source code
D) byte code
E) pseudo code

A

D)
The Java compiler generates byte code.

25
Q

Which of the following statements are true regarding interpreters?

A) They use a three step approach of edit, compile, and run.
B) The source code file and the executable file are the same.
C) They recompile each statement every time the program runs.
D) Once a program runs perfectly, interpreters are faster than non- interpretive language programs.
E) They use a two step approach that combines the compile and run steps into one step.

A

B) C) E)

Interpretive languages, such as BASIC, translate and execute each statement as they come to it. They will stop executing a program when an individual statement is found to be invalid. Because they compile each statement each time the program is executed, this is a time-consuming way to run perfected programs.

26
Q

Given two variables x and y, which code below swaps the current values of x and y?

A) y = x; x = y;
B) x = y; y = x;
C) t = x; y = x; y = t;
D) t = x; x = y; y = t;

A

D)

Using a temporary variable, store the current value of one of the variables, say x. x now can store the current value of y. y gets the current value of x from the temporary variable.

27
Q

What is a Java Virtual Machine (JVM)?

A) a language run-time environment
B) a compiler
C) an editor specific to Java
D) a pseudo code generator

A

A)

28
Q

Which of the following are valid Java variable names?

A) OVER_THE_TOP
B) $MINIMUM
C) Year2011
D) 2for_one_sale
E) over_the_top

A

A) B) C) E)

Java gives great latitude in the formulation of names for variables. The rules are: the first character must be one of the letters a-z, A-Z, an underscore, or a dollar sign. After the first character, you may use the letters a-z or A-Z, the digits 0-9, underscores or dollar signs. Names cannot include spaces.

29
Q

Which of the following statements are true regarding the following Java statement?
average = (x + y)/2.0

A) This statement is an algebraic equality statement.
B) If the value of all variables in this statement was always guaranteed to be a round number, all variables would best be defined as integer.
C) This statement contains two variables.
D) This statement is an assignment statement.

A

D)

This is an assignment statement, which assigns a value to the variable called average. It contains three variables (average, x and y). Even if the value of all variables was always guaranteed to be a round number, they should still all be defined as doubles, because if the sum of x and y were an odd number, the resulting average would have a fractional component. Note that round is not synonymous with even.

30
Q

Which of the following are true about Java assignment statements?

A) In a Java assignment statement there can be multiple variables and constants on the left of the assignment operator
B) A Java assignment statement is the same as an algebraic equality statement
C) Java assignment statements use the = operator
D) Java assignment statements can have an arithmetic expression on the right of the assignment operator

A

C) D)

Java assignment statements consist of a variable, a = operator, and possibly an arithmetic expression to the right of the = operator.

31
Q

Which of the following are derived data types in the Java language?

A) char
B) String
C) double
D) indirection
E) []

A

B) E)

Char and double are primitive data types. [] is correct, because it specifies an array datatype. Indirection suggests a datatype, but is not itself a datatype.

32
Q

Which of the following are true about arithmetic expressions?

A) 5 * 4 / 4 - 1 is equal to 6
B) Subtraction is always done after addition
C) Multiplication is always done before addition (assume no parenthesis)
D) 1 + 2 * 3 is equal to 7
E) 6 + 4 / 2 is equal to 5

A

C) D)

The order of precedence is parentheses, multiplication/division and finally addition/subtraction

33
Q

Which of the following are valid Java declarations and initializations of variables?

A) char n = “Hello”;
B) short x = 4.26;
C) int x = 1000000;
D) boolean true = yes;
E) constant PI = 3.1416;

A

C)

An integer of one million is valid. The range for Feedback: integers extends up over 2 billion. Booleans are a
binary toggle value of True or False (not yes). A short is an integer. Char data types can only contain one character, not multiple characters, and is delineated by single quotes, not double quotes. Constant is not a valid data type in Java.