Lewis Complete Test Bank Introduction Ch.1 - Instructor Test Bank | Java Foundations 5e Lewis by John Lewis. DOCX document preview.
Chapter 1: Introduction
Multiple Choice Questions:
1) _____________ consists of specific words and symbols to express a problem solution.
a) A programming language
b) Software
c) Hardware
d) A computer
e) An application
2) Java is _____________________.
a) a procedural language
b) a functional language
c) an object-oriented language
d) a fourth-generation language
e) a spoken-language
3) Problem domain describes
a) the set of problems that are encountered when testing a program
b) the alternate ways to design the solution
c) the challenges in implementing the solution
d) the real-world issues that are key to a solution
e) all of the above
4) In order for a program to run on a computer, it must be expressed in ______________________.
a) an assembly language
b) a machine language
c) a high-level language
d) an object-oriented language
e) a fourth generation language
5) A syntax error is a _____________________.
a) a logical error
b) a compile-time error
c) a run-time error
d) a bug
e) an exception
6) Which of the following is not one of the four basic software development activities?
a) establishing the requirements
b) creating a design
c) preliminary practice coding
d) testing
e) implementing the design
7) Software requirements specify ____________________.
a) what a program should accomplish
b) which programming language the developer should use
c) how objects should be encapsulated
d) how a solution should be implemented
e) a programming schedule
8) The _____________ of an object define it define its potential behaviors.
a) attributes
b) white spaces
c) variables
d) methods
e) name
9) Which of the following will is considered a logical error?
a) forgetting a semicolon at the end of a programming statement
b) typing a curly bracket when you should have typed a parenthesis
c) multiplying two numbers when you meant to add them
d) dividing by zero
e) misspelling an identifier
10) Which of the following lines is a properly formatted comment?
a) // This is a comment
b) /* This is a comment */
c) /*
this is a comment
*/
d) both a and b
e) a, b and c
11) The Java compiler translates Java source code into _____________ .
a) Java bytecode
b) C++
c) assembly code
d) machine code
e) an object-oriented language
12) Classes can be created from other classes by using _______________ .
a) encapsulation
b) polymorphism
c) inheritance
d) attributes
e) machine code
13) Which of the following is not a valid Java identifier?
a) answer_7
b) highest$
c) anExtremelyLongIdentifierIfYouAskMe
d) 2ndlevel
e) thirdNumber
14) Which task(s) is/are done in the implementation activity in the software development process?
a) specify what the program must accomplish
b) determine how a program will accomplish its requirements
c) write the source code that will solve the problem
d) ensure that the program solves the targeted problem
e) all of the above
15) Which of the following describes the act of ensuring that a program solves the intended problem in all cases?
a) establishing the requirements
b) testing
c) preliminary practice coding
d) implementing the design
e) creating a design
1) An editor is typically included as part of an IDE.
2) Comments affect the run-time execution of a program.
3) A reserved word can be used to name a method.
4) "Purchase a computer" is one of the problem-solving steps.
5) In Java, total, ToTal and TOTAL are all different identifiers.
6) Testing is the act of ensuring that a program will solve the targeted problem.
7) The attribute of an object defines its potential behaviors
8) An interpreter is a program that translates code that is written in one language into equivalent code in another language.
9) Syntax rules dictate the form of a program. Semantics dictate the meaning of the program statements.
10) An object should never be encapsulated.
1) Explain why "Understand the problem" is the first activity in problem solving.
2) Write a short Java program that outputs the following:
*
*
*
************** Time flies like an arrow
*
*
*
public class Arrow {
public static void main(String [] args) {
System.out.println(" *");
System.out.println(" *");
System.out.println(" *");
System.out.println(" ************** Time flies like an arrow");
System.out.println(" *");
System.out.println(" *");
System.out.println(" *");
}
}
3) Why is testing part of the problem-solving process?
4) Identify the syntax errors in the following snippet of code:
public clas Hello {
public static void main(String [] args) {
Sytem.out.println("Hello Wrld!")
}
}
5) Explain the difference between the syntax of a program and the semantics of a program.
6) Why is ambiguity a problem for programming languages?
7) Why is it important to consider alternate solutions to a problem?
8) Why is inheritance a form of software reuse?
9) Determine a good identifier for each of the following entities in a program that calculates the final grade:
a) A grade on the first test of the semester
b) The total number of tests
c) The total number of homework assignments
d) The relative weight of the tests
a) firstTest
b) totalNumTests
c) totalNumAssn
d) testWeight
Note that there are other descriptive identifiers that can be used for each of these.
10) Explain the difference between a compile-time error and a run-time error. Give an example of each.
11) What are the primary concepts that support object-oriented programming?
12) What are some advantages to writing programs in a high-level language instead of machine code?
13) Name the four basic activities that are involved in a software development process.
14) Write a program that outputs Four Score and Seven Years Ago on six lines, with the words centered relative to each other.
public class Lincoln {
public static void main(String [] args) {
System.out.println(" Four ");
System.out.println("Score");
System.out.println(" and ");
System.out.println("Seven");
System.out.println("Years");
System.out.println(" Ago ");
}
}
15) Give three examples of Java reserved words.