100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

Absolute Java 5th Edition by Walter Savitch -  Test Bank

Rating
-
Sold
-
Pages
226
Grade
A
Uploaded on
20-09-2023
Written in
2022/2023

Chapter 3 Flow of Control  Multiple Choice 1) An if selection statement executes if and only if: (a) the Boolean condition evaluates to false. (b) the Boolean condition evaluates to true. (c) the Boolean condition is short-circuited. (d) none of the above. Answer: B 2) A compound statement is enclosed between: (a) [ ] (b) { } (c) ( ) (d) < > Answer: B 3) A multi-way if-else statement (a) allows you to choose one course of action. (b) always executes the else statement. (c) allows you to choose among alternative courses of action. (d) executes all Boolean conditions that evaluate to true. Answer: C 4) The controlling expression for a switch statement includes all of the following types except: (a) char (b) int (c) byte (d) double Answer: D ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1 2 Walter Savitch • Absolute Java 5/e: Chapter 3 Test Bank 5) To compare two strings lexicographically the String method ____________ should be used. (a) equals (b) equalsIgnoreCase (c) compareTo (d) == Answer: C 6) When using a compound Boolean expression joined by an && (AND) in an if statement: (a) Both expressions must evaluate to true for the statement to execute. (b) The first expression must evaluate to true and the second expression must evaluate to false for the statement to execute. (c) The first expression must evaluate to false and the second expression must evaluate to true for the statement to execute. (d) Both expressions must evaluate to false for the statement to execute. Answer: A 7) The OR operator in Java is represented by: (a) ! (b) && (c) | | (d) None of the above Answer: C 8) The negation operator in Java is represented by: (a) ! (b) && (c) | | (d) None of the above Answer: A 9) The ____________ operator has the highest precedence. (a) * (b) dot (c) += (d) decrement Answer: B ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. (b) Continue (c) Switch (d) Assert Answer: B Chapter 3 Flow of Control 3 10) The association of operands with operators is called ______________. (a) assignment (b) precedence (c) binding (d) lexicographic ordering Answer: C 11) The looping mechanism that always executes at least once is the _____________ statement. (a) if...else (b) do...while (c) while (d) for Answer: B 12) A mixture of programming language and human language is known as: (a) Algorithms (b) Recipes (c) Directions (d) Pseudocode Answer: D 13) When the number of repetitions are known in advance, you should use a ___________ statement. (a) while (b) do...while (c) for (d) None of the above Answer: C 14) A ___________ statement terminates the current iteration of a loop. (a) Break ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 4 Walter Savitch • Absolute Java 5/e: Chapter 3 Test Bank 15) Common loop errors are: (a) Off-by-one (b) Infinite loops (c) Bothaandb (d) None of the above Answer: C 16) To terminate a program, use the Java statement: (a) S(0); (b) S(0); (c) S(0); (d) S(0); Answer: D 17) Good debugging techniques include: (a) Inserting output statements in your program. (b) Tracing variables (c) Using an IDE debugger (d) All of the above Answer: D  True/False 1) An if-else statement chooses between two alternative statements based on the value of a Boolean expression. Answer: True 2) You may omit the else part of an if-else statement if no alternative action is required. Answer: True 3) In a switch statement, the choice of which branch to execute is determined by an expression given in parentheses after the keyword switch. Answer: True 4) In a switch statement, the default case is always executed. Answer: False 5) Not including the break statements within a switch statement results in a syntax error. Answer: False ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 6) The equality operator (==) may be used to test if two string objects contain the same value. Answer: False 7) Boolean expressions are used to control branch and loop statements. Answer: True 8) The for statement, do...while statement and while statement are examples of branching mechanisms. Answer: False 9) When choosing a sentinel value, you should choose a value that would never be encountered in the input of the program. Answer: True 10) An algorithm is a step-by-step method of solution. Answer: True 11) The three expressions at the start of a for statement are separated by two commas. Answer: False 12) An empty statement is defined as a loop that runs forever. Answer: False  Short Answer/Essay What output will be produced by the following code? public class SelectionStatements { public static void main(String[] args) { int number = 24; if(number % 2 == 0) ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 3 Flow of Control 5 6 Walter Savitch • Absolute Java 5/e: Chapter 3 Test Bank S("The condition evaluated to true!"); else } } The condition evaluated to true! S("The condition evaluated to false!"); 1) What would be the output of the code in #1 if number was originally initialized to 25? 2) The condition evaluated to false! 3) Write a multi-way if-else statement that evaluates a persons weight on the following criteria: A weight less than 115 pounds, output: Eat 5 banana splits! A weight between 116 pounds and 130 pounds, output: Eat a banana split! A weight between 131 pounds and 200 pounds, output: Perfect! A weight greater than 200 pounds, output: Plenty of banana splits have been consumed! 4) ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. if(weight <= 115) Sln("Eat 5 banana splits!"); else if(weight <= 130) Sln("Eat a banana split!"); else if(weight <=200) Sln("Perfect!"); else Sln("Plenty of banana splits have been consumed!"); 5) Name and describe three types of branching mechanisms and give an example of each. 6) Three types of branching mechanisms include the if-else statement, the multi-way if-else statement, and the switch statement. An if-else statement chooses between two alternative statements based on the value of a Boolean expression. If you only need to perform an action if a certain condition is true, then the else part of an if-else statement can be omitted. A multi-way if- else statement allows several conditions to be evaluated. The first condition that evaluates to true, is the branch that is executed. The switch statement is another multi-selection branching mechanism. A switch evaluates a controlling expression and executes the statements in the matching case label. If – else example: if ( taxableIncome > 30000) taxRate = .135; else taxRate = .075; Multi-way if-else example: If(taxableIncome < 10000) Switch example: taxRate = .0425; else if(taxableIncome < 30000) taxRate = .075; else taxRate = .135; char myChar = ‘b’; switch(myChar) { ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 3 Flow of Control 7 8 Walter Savitch • Absolute Java 5/e: Chapter 3 Test Bank case ‘a’: Sln(“It is an A”); break; case ‘b’: Sln(“It is a B”); break; case default: Sln(“Default case”); break; } Write an if-else statement to compute the amount of shipping due on an online sale. If the cost of the purchase is less than $20, the shipping cost is $5.99. If the cost of the purchase over $20 and at most $65, the shipping cost is $10.99. If the cost of the purchase is over $65, the shipping cost is $15.99. if(costOfPurchase < 20) shippingCost = 5.99; else if((costOfPurchase > 20)&&(costOfPurchase <= 65)) shippingCost = 10.99; else 1) Evaluate the Boolean equation: !( ( 6 < 5) && (4 < 3)) 2) True 3) What is short-circuit evaluation of Boolean expressions? 4) Short-circuit evaluation is a mechanism in Java that allows the early termination of the evaluation of a compound Boolean expression. This occurs when two Boolean expressions are joined by the && operator when the first expression evaluates to false. The evaluation short-circuits because no matter what the value of the second expression is, the expression will evaluate to false. When two Boolean expressions are joined by the || operator, if the first expression evaluates to true, then the evaluation will short circuit because the expression will always evaluate to true no matter what the second expression evaluates to. shippingCost = 15.99; ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 5) Discuss the rules Java follows when evaluating expressions. 6) First, Java binds operands with operators by fully parenthesizes the expression using precedence and associativity rules. Next, Java evaluates expressions from left to right. Finally, if an operator is waiting for other operands to be evaluated, then that operator is evaluated as soon as its operands have been evaluated. 7) Write Java code that uses a do...while loop that prints even numbers from 2 through 10. 8) int evenNumber = 2; do { Sln(evenNumber); evenNumber += 2; }while(evenNumber <= 10); 9) Write Java code that uses a while loop to print even numbers from 2 through 10. 10) int evenNumber = 2; while(evenNumber <= 10) { Sln(evenNumber); evenNumber += 2; } ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 3 Flow of Control 9 10 Walter Savitch • Absolute Java 5/e: Chapter 3 Test Bank 11) What is a sentinel value and how is it used? 12) A sentinel value is a value that should never be encountered in the input of the program. It is used to control looping mechanisms when the number of repetitions is unknown. When the sentinel value is encountered, the loop terminates. A sentinel value is commonly used with while and do....while statements. 13) Write Java code that uses a for statement to sum the numbers from 1 through 50. Display the total sum to the console. 14) int sum = 0; for(int i=1; i <= 50; i++) { sum += i; } Sln("The total is: " + sum); 15) What is the output of the following code segment? public static void main(String[] args) { int x = 5; Sln("The value of x is:" + x); while(x > 0) { x++; } ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 19) import .Scanner; public class FindMin { public static void main(String[] args) { Scanner keyboard = new Scanner(S); int smallest = 9999999; String userInput; boolean quit = false; ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 3 Flow of Control 11 Sln("The value of x is:" + x); } Answer: The value of x is 5. The program then enters an infinite loop because the value of x is always greater than 0. 16) Discuss the differences between the break and the continue statements when used in looping mechanisms. 17) When the break statement is encountered within a looping mechanism, the loop immediately terminates. When the continue statement is encountered within a looping mechanism, the current iteration is terminated, and execution continues with the next iteration of the loop. 18) Write a complete Java program that prompts the user for a series of numbers to determine the smallest value entered. Before the program terminates, display the smallest value. 12 Walter Savitch • Absolute Java 5/e: Chapter 3 Test Bank Sln("This program finds the smallest number" + " in a series of numbers"); Sln("When you want to exit, type Q"); while(quit != true) { S("Enter a number: "); userInput = (); if(userIs("Q") || userIs("q")) { quit = true; } else { int userNumber = IInt(userInput); if(userNumber < smallest) ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. } } Sln("The smallest number is " + smallest); S(0); } } 20) Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 25. public class sumEvenOdd { public static void main(String[] args) { int evenSum = 0; int oddSum = 0; //loop through the numbers for(int i=1; i <= 25; i++) { if(i % 2 == 0) ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 3 Flow of Control 13 smallest = userNumber; 14 Walter Savitch • Absolute Java 5/e: Chapter 3 Test Bank { //even number evenSum += i; } else { oddSum += i; } } //Output the results Sln("Even sum = " + evenSum); Sln("Odd sum = " + oddSum); Chapter 5 Defining Classes II  Multiple Choice 1) A static method is one that can be used with a _____________. (a) instance variable (b) local variable (c) global variable (d) the class name as a calling object Answer: D 2) Static variables are often used: (a) in arithmetic expressions (b) to communicate between objects (c) within looping structures (d) all of the above Answer: B 3) Only ______ copy/copies of a static variable are available to objects of a class. (a) one (b) two (c) three (d) none of the above Answer: A 4) All of these are methods of Java’s Math class except: (a) pow (b) min (c) random (d) toString Answer: D ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1 2 Walter Savitch • Absolute Java 5/e 5) The Math method that returns the nearest whole number that is greater than or equal to its argument is: (a) round (b) ceil (c) floor (d) all of the above Answer: B 6) All of the following are wrapper classes except: (a) String (b) Integer (c) Character (d) Double Answer: A 7) Converting from a value of primitive type to a corresponding object of its associated wrapper class is called: (a) Boxing (b) Unboxing (c) Converting (d) Reinstantiating Answer: A 8) The conversion from an object of a wrapper class to a value of its associated primitive type is called: (a) Boxing (b) Unboxing (c) Converting (d) Reinstantiating Answer: B 9) The method trim of the String class trims off: (a) Leading white space (b) Trailing white space (c) Leading and trailing white space (d) Blanks Answer: C ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Answer: B Chapter 5 Defining Classes II 3 10) An example of secondary memory is: (a) RAM (b) ROM (c) hard disk (d) all of the above Answer: C 11) When you use the assignment operator with variables of a class type, you are assigning a: (a) value (b) primitive type (c) local variable (d) reference Answer: D 12) null can be used: (a) to indicate a variable has no real value (b) in a Boolean expression with == (c) as a placeholder (d) all of the above Answer: D 13) A copy constructor has _________ parameters. (a) zero (b) one (c) two (d) three Answer: B 14) A condition that allows a programmer to circumvent the private modifier and change the private instance variable is called: (a) a copy constructor (b) a privacy leak (c) a class invariant (d) an anonymous object ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 4 Walter Savitch • Absolute Java 5/e 15) A class that contains public methods that can change the data in the object of a class is called a/an: (a) mutable class (b) immutable class (c) invariant class (d) none of the above Answer: A 16) To create a package, you must add a package statement at the ____________ of each class file. (a) beginning (b) end (c) before each method signature (d) after the import statements Answer: A 17) The program included in the Java SDK that allows a programmer to separate the class interface from the class implementation is called: (a) javac (b) java (c) javadoc (d) none of the above Answer: C 18) Javadoc requires a comment to be delimited by _________ to be included in the extracted class interface. (a) // // (b) /* */ (c) /** */ (d) “ “ Answer: C  True/False 1) In a static method, you may use the this parameter either explicitly or implicitly. Answer: False 2) A main method can be placed inside a class definition. Answer: True 3) You may use methods of the Math class without an import statement. Answer: True ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 4) Wrapper classes provide a class type corresponding to each of the primitive types so that you can have class types that behave somewhat like primitive types. Answer: True 5) All versions of Java support automatic boxing. Answer: False 6) Wrapper classes are provided for all primitive Java types except Boolean. Answer: False 7) Abitmayhavethevalueofeithera1or0. Answer: True 8) Primitive types are reference types. Answer: False 9) A class invariant is a statement that is always true for every object of the class. Answer: True 10) You should avoid the use of null as an argument to a method. Answer: False 11) The String class is a mutable class. Answer: False 12) To use a package, the program must contain an import statement that names the package. Answer: True 13) Deprecated methods should be used in new Java code. Answer: False  Short Answer/Essay Write a statement that creates and initializes a static variable named salesTax to 7.59. private static double salesTax = 7.59; Write a statement that creates a constant variable named TAX_RATE. The tax rate is 8.25%. public static final double TAX_RATE = .0825; ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 5 Defining Classes II 5 6 Walter Savitch • Absolute Java 5/e Write ONE Java statement that computes and displays the value of 2 . 5 Sln("The value of 2 raised to the 5th power is " + M(2,5)); Write ONE Java statement that computes and displays a random number between 1 and 25. Sln("Random number between 1 and 25 " + M((Mm() * 25))); Define boxing and unboxing. Boxing and unboxing are terms that refer to either wrapping up a primitive type or unwrapping an object back into a primitive type. More specifically, boxing is the process of going from a value of a primitive type to an object of its wrapper class. Unboxing is the process of going from an object of a wrapper class to the corresponding value of a primitive type. Write a complete Java program that prompts the user for a number and prints back the integer as well as floating point values to the console. import .Scanner; public class WrapperDemo { public static void main(String args[]) { Scanner keyboard = new Scanner(S); S("Enter any number >> "); String strNumber = (); int intNumber = IInt(strNumber); double dblNumber = DDouble(strNumber); Sln("The integer value of " + strNumber + " is: " + ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. } } intNumber); Sln("The floating-point value of " + strNumber + " is: " + dblNumber); Write a Java method that returns true if and only if a character is a digit or a letter. The method should display appropriate feedback to the console. public boolean isDigitOrLetter(Character c) { if(Digit(Value()) || Letter(Value())) { Sln("Returning true"); return true; } else { ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Sln("Returning false"); return false; Chapter 5 Defining Classes II 7 8 Walter Savitch • Absolute Java 5/e } } Explain in detail how main memory works. The main memory is used by the computer when it is running a program. Values stored in a program’s variables are kept in this main memory as well as the byte-code of the program. Main memory consists of a long list of numbered locations called bytes. The number that identifies the byte is called the address. A data item can be stored in one or more of those bytes, and the address of the byte is then used to locate the data item when it is needed. How many bytes are contained within 16-bits, 32-bits, 64-bits? 16-bits contain 2-bytes; 32-bits contain 4-bytes, 64-bits contain 8-bytes. When used with objects, what is the equality ( == ) operator really comparing? The == operator does not check that the objects have the same values for instance variables. It checks for equality of memory address, so two objects in two different locations in memory would test as being “not equal” when compared using ==, even if their instance variables contain equivalent data. Does an object created with a copy constructor reference the same memory location that the original object references? Explain. If properly coded, a copy constructor should create an object that is separate from the original object, that is each object should have distinct memory locations. The new object created by the copy constructor will have instance variables with the same values as the original object. Explain how a package is named in Java. A package name is a form of path name to the directory containing the classes in the package. The name of the package specifies the relative path for the directory that contains the package classes. The or / (depending on the operating system being used) is replaced by a dot to form a fully qualified package name. Create a Java class named Book with instance variables title, author, ISBN, and yearPublished. Include javadoc style comments to describe your interface. Such a class would normally have methods, but you are not required to supply any methods. /** Class for a book with title, author, ISBN and year published. Class invariant: A Book always has a title and author. */ ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. public class Book { /** Instance variables */ private String title; private String author; private String ISBN; private int yearPublished; } Add accessor and mutator methods to the Book class created in question #13. /** Class for a book with title, author, ISBN and year published. Class invariant: A Book always has a title and author. */ public class Book { /** Instance variables */ private String title; private String author; private String ISBN; ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 5 Defining Classes II 9 10 Walter Savitch • Absolute Java 5/e private int yearPublished; /** Accessor methods */ public String getTitle() { return title; } public String getAuthor() { return author; } public String getISBN() { return ISBN; } public int getYearPublished() { return yearPublished; ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. } /** Mutator methods */ public void setISBN(String isbn) { ISBN = isbn; } public void setYearPublished(int y) { yearPublished = y; } /** Facilitator methods */ public String toString() { return (title + " " + author + " " + ISBN + " " + yearPublished); } public boolean equals(Book otherBook) { if(otherBook == null) ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 5 Defining Classes II 11 12 Walter Savitch • Absolute Java 5/e return false; else return (s(otherB) && s(otherBr) && ISBN.equals(otherBook.ISBN) && yearPublished == otherBPublished); } } Add a constructor and a copy constructor to the Book class created in question #13. public Book(String t, String a) { title = t; author = a; setISBN(null); setYearPublished(0); } public Book(String t, String a, String i, int y) { ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. title = t; author = a; setISBN(i); setYearPublished(y); } public Book(Book original) { if(original == null) { Sln("Fatal error"); S(0); } title = ; author = r; ISBN = original.ISBN; yearPublished = Published; } Chapter 5 Defining Classes II 13 ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 14 Walter Savitch • Absolute Java 5/e 1) What is the purpose of Java’s wrapper classes? 2) The wrapper classes contain a number of useful constants and static methods. Wrapper classes accomplish two tasks: they produce class objects corresponding to values of primitive types, and they supply useful constants and methods. 3) Write a complete Java program that prompts the user for a phrase. The program converts and displays the phrase in uppercase letters. import .Scanner; public class convertToUpper { public static void main(String[] args) { //Create a scanner object for input Scanner keyboard = new Scanner(S); Sln("Enter a phrase and I'll convert it to uppercase."); String phrase = Line(); Sln(UpperCase()); } Write a complete Java program using the StringTokenizer class that computes and displays the average of a list of grades read from the command line. Each grade should be entered on the same line separated by commas. Enter signifies the end of the input. import .Scanner; ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. } import .StringTokenizer; public class tokenAverager { public static void main(String[] args) { //Local variables Scanner keyboard = new Scanner(S); int sum = 0; int count = 0; double average = 0; Sln("Enter your grades, placing a space between each grade."); Sln("Press enter when you are finished."); String grades = Line(); StringTokenizer tk = new StringTokenizer(grades, " "); while(MoreTokens()) { sum += IInt(Token()); count++; ©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Chapter 5 Defining Classes II 15 16 Walter Savitch • Absolute Java 5/e } average = sum/count; Sln("The class average is " + average); } absolute java - test bank, absolute java, absolute java 5th edition pdf, b java, find absolute value java,

Show more Read less
Institution
Module











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

Written for

Institution
Study
Module

Document information

Uploaded on
September 20, 2023
Number of pages
226
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

,Chapter 1
Getting Started


 Multiple Choice
1) Java is an object-oriented programming language. An object-oriented language
(a) Uses structured programming.
(b) Views a program as consisting of objects which communicate through interactions.
(c) Functionally breaks down problems into smaller, more manageable problems.
(d) All of the above.
Answer: B

2) In Java, the equal sign is used as the ___________ operator.
(a) increment
(b) decrement
(c) assignment
(d) negation
Answer: C

3) In Java, source code is compiled into object code called ______________.
(a) Bit-code
(b) Class code
(c) Method code
(d) Byte-code
Answer: D

4) The hardest kind of error to detect in a computer program is a:
(a) Syntax error
(b) Run-time error
(c) Logic error
(d) All of the above
Answer: C



©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.

1

,2 Walter Savitch • Absolute Java 5/e: Chapter 1 Test Bank


5) Identify the invalid Java identifier.
(a) 1Week
(b) Week1
(c) amountDue
(d) amount_due
Answer: A

6) What is the value of the variable amountDue?

double price = 2.50;

double quantity = 5;

double amountDue = 0;

amountDue = price * quantity;

(a) 12
(b) 12.25
(c) 12.5
(d) 13
Answer: C

7) What is the value of 7.52e-5?
(a) 752000.0
(b) 0.0000752
(c) 0.000752
(d) 0.00752
Answer: B

8) What is the Java expression for 4a2 + 2b * c?
(a) (4 * a) + (2 * b) * c
(b) (4 * a * a) + ((2 * b) * c)
(c) ((4 * a * a) + (2 * b)) * c
(d) (4 + a * a) + ((2 + b) * c)
Answer: B

9) What is the Java expression for 27xy?
(a) 27 + (x * y)
(b) 27 * (x + y)
(c) 27 * x * y
(d) 27x * y
Answer: C



©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.

, Chapter 1 Getting Started 3


10) The value of the expression (int) 27.6 evaluates to:
(a) 28
(b) 27
(c) 26
(d) None of the above.
Answer: B

11) Which operator is used to concatenate two strings?
(a) +
(b) –
(c) *
(d) /
Answer: A

12) Which operator returns the remainder of integer division?
(a) %
(b) /
(c) *
(d) none of the above
Answer: A

13) What is the value of the variable c in the statements that follow?

String phrase = "Make hay while the sun is shining.";

char c = phrase.charAt(10);
(a) w
(b) h
(c) i
(d) None of the above
Answer: B

14) The escape sequence the represents the new-line character is:
(a) \r
(b) \t
(c) \n
(d) \\
Answer: C




©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.

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.
ExamsExpert (self)
Follow You need to be logged in order to follow users or courses
Sold
629
Member since
2 year
Number of followers
313
Documents
2838
Last sold
14 hours ago
ExamsExpert

We as a team provide best and Latest Test Banks that helps students to get A Grade we have vast range of test banks you can order us any test bank that you need

4.5

87 reviews

5
60
4
15
3
9
2
1
1
2

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions