Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

QuestionBank_Ch02-10 Java How to Program, 11/e Multiple Choice Test Bank. Chapter 2 Introduction to Java Applications

Rating
-
Sold
1
Pages
66
Grade
A+
Uploaded on
12-07-2022
Written in
2021/2022

Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two forward slashes (//). b. Three forward slashes (///). c. A slash and a star (/*). d. A slash and two stars (/**). ANS: a. Two forward slashes (//). 2.2 Q2: Which of the following is not a valid Java identifier? a. my Value b. $_AAA1 c. width d. m_x ANS: a. my Value (Identifiers may not contain blanks). 2.2 Q3: Which of the following cannot cause a syntax error to be reported by the Java compiler? a. Mismatched {} b. Missing */ in a comment that begins with /* c. Missing ; d. An extra blank line. ANS: d. An extra blank line. 2.2 Q4: Which of the following does not contain a syntax error? a. Sln('Hello world!'): b. Sln("Hello world!"); c. Sln("Hello world!"); d. Sln(Hello world!); ANS: c. Sln("Hello world!"); Compiling and Executing Your First Java Application 2.2 Q5: Which command compiles the Java source code file W? a. cd W b. javac W c. java W d. compile W ANS: b. javac W 2.2 Q6: Which command executes the Java class file W? a. java welcome b. java W c. java Welcome d. run W ANS: c. java Welcome (Note that you must use the same capitalization as the class name.) Java How to Program, 11/e Multiple Choice Test Bank Page 2 of 66 Page 2 of 66 Section 2.3 Modifying Your First Java Program Displaying a Single Line of Text with Multiple Statements 2.3 Q1: Which is the output of the following statements? S("Hello "); Sln("World"); a. Hello World b. HelloWorld c. Hello World d. World Hello ANS: a. Hello World Displaying Multiple Lines of Text with a Single Statement 2.3 Q2: Which of the following is the escape character? a. * b. c. n d. " ANS: b. 2.3 Q3: Which of the following statements will print a single line containing "hello there"? a. Sln("hello"); Sln(" there"); b. Sln("hello" , " there"); c. Sln("hello"); S(" there"); d. S("hello"); Sln(" there"); ANS: d. S("hello"); Sln(" there"); 2.3 Q4: Which of the following escape sequences represents a carriage return? a. n. b. r. c. cr. d. c. ANS: b. r. 2.3 Q5: Which of the following statements would display the phase Java is fun? a. Sln("hellois funrJava "); b. Sln('Java is fun'); c. Sln(""Java is fun""); d. Sln(Java is fun); ANS: a. Sln("hellois funrJava "); Java How to Program, 11/e Multiple Choice Test Bank Page 3 of 66 Page 3 of 66 Section 2.4 Displaying Text with printf 2.4 Q1: When method printf requires multiple arguments, the arguments are separated with ________. a. colons (:). b. semicolons (;). c. commas (,). d. periods (.). ANS: c. commas (,). 2.4 Q2: Which of the following statement displays Hello World? a. Sf("%2s", "Hello " "World"); b. Sf("%s %s", "Hello", "World"); c. Sf("%s%s", "Hello, World"); d. Sf("s% s%", "Hello", "World"); ANS: b. Sf("%s %s", "Hello", "World"); Section 2.5 Another Application: Adding Integers 2.5 Q1: Programs remember numbers and other data in the computer's memory and access that data through program elements called a. comments. b. messages. c. integers. d. variables. ANS: d. variables. Section 2.5.1 import Declarations 2.5.1 Q1: All import declarations must be placed a. inside the class declaration’s body. b. before the class declaration. c. after the class declaration. d. all of the above will work. ANS: b. before the class declaration. 2.5.1 Q2: Java's predefined classes are grouped into a. packets. b. declarations. c. Galleries. d. packages. ANS: d. packages. Section 2.5.2 Declaring and Creating a Scanner to Obtain User Input from the Keyboard 2.5.3 Q1: Which of the following is a variable declaration statement? a. int total; b. import .Scanner; Java How to Program, 11/e Multiple Choice Test Bank Page 4 of 66 Page 4 of 66 c. public static void main(String args[]) d. // first string entered by user ANS: a. int total; 2.5.3 Q2: A(n) ________ enables a program to read data from the user. a. printf. b. import declaration. c. Scanner. d. main. ANS: c. Scanner. Section 2.5.3 Prompting the User for Input 2.5.5 Q1: Which of the following statements is true? a. S("Enter your age: "); prompts the user to take action. b. Class names typically begin with a capital letter. c. Package is imported in every Java program. d. All of the above are true. ANS: d. All of the above are true. Section 2.5.4 Declaring a Variable to Store an Integer and Obtaining an Integer from the Keyboard 2.5.4 Q1: Which of the following is not a Java primitive type? a. char b. byte c. real d. double ANS: c. real 2.5.4 Q2: Which of the following statements is false? a. Primitive types are keywords. b. Primitive types must appear in all lowercase letters. c. Real numbers contain decimal points. d. Variable name identifiers must begin with a lowercase letter. ANS: d. Variable name identifiers must begin with a lowercase letter. This is not required, but it is a convention. Section 2.5.5 Obtaining a Second Intege 2.5.6 Q1: Which of the following is a Scanner method for inputting an integer value? a. nextInteger b. integer c. nextInt d. int ANS: c. nextInt. 2.5.6 Q2: Given the Java statement ...

Show more Read less
Institution
NET MISC
Course
NET MISC











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
NET MISC
Course
NET MISC

Document information

Uploaded on
July 12, 2022
Number of pages
66
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

  • net misc
$15.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Accurate Accounting
View profile
Follow You need to be logged in order to follow users or courses
Sold
521
Member since
4 year
Number of followers
268
Documents
12459
Last sold
2 weeks ago
Accurate Solutions

The Right Documents (PDFs)...at the right price #Don't Forget To Leave A Great Review! #Don't Forget To Leave A Great Review!

4.1

79 reviews

5
45
4
14
3
9
2
3
1
8

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions