Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 An IDE typically stores all of the files for an application in a a. package b. class c. library d. project 2 points

Question 1 An IDE typically stores all of the files for an application in a a. package b. class c. library d. project 2 points Question 2 Javas syntax is similar to the syntax of ________. 2 points Question 3 You can use relational operators to a. compare string variables b. compare numeric variables c. both a and b d. neither a nor b 2 points Question 4 Which of the following statements prints a variable named total to the console, followed by a new line character? a. Console.out.print(total); b. Console.out.println(total); c. System.out.print(total); d. System.out.println(total); 2 points Question 5 A compile-time error occurs when a. the class doesnt contain a main() method b. theres a syntax error in a Java statement c. bytecode cant be interpreted properly d. the Java compiler cant be located 2 points Question 6 The process of finding and fixing the errors in an application is called ____________. 2 points Question 7 You use an escape sequence to a. append a string expression to a string variable b. include a special character in a string c. indicate the beginning of a literal string d. indicate the beginning of a comment 2 points Question 8 How many times will the while loop that follows be executed if months has a value of 5? int i = 1; while (i < months) { futureValue = futureValue * (1 + monthlyInterestRate); i = i+1; } a. 0 b. 4 c. 5 d. 6 2 points Question 9 Which of the following can you not assign to a numeric variable? a. another numeric variable b. a numeric literal c. an arithmetic expression d. null 2 points Question 10 You can store a value that cant be changed as an application executes in a ____________. 2 points Question 11 If an integer value is too big for the int data type, you should store it in the ____________ data type. 2 points Question 12 Which of the following statements calculates the change in sales between two double variables named this YTDSales and lastYTDSales, rounds the result to an integer, and stores it in an integer in an int variable named salesChange? a. int salesChange = (int) thisYTDSales - (int) lastYTDSales; b. int salesChange = Math.round(thisYTDSales - lastYTDSales, 0); c. int salesChange = (int)(thisYTDSales - lastYTDSales); d. int salesChange = Math.round(thisYTDSales - lastYTDSales); 2 points Question 13 If the int variables a = 5, b = 2, and c = 10, what is the value of c after the following statement is executed? c = c + a * b 5; a. -45 b. 15 c. 25 d. None of the above 2 points Question 14 If the variable named input is 755, what is the value of r after these statements are executed? NumberFormat n = NumberFormat.getNumberInstance(); n.setMinimumFractionDigits(3); String r = n.format(input); a. 755 b. 755.000 c. 760.000 d. .755 2 points Question 15 What is the value of maxNumber after the code that follows is executed? int number = 0; int maxNumber = 0; for (int i = 0; i <= 10; i++) { number = (int)(Math.random() * 100); if (number >= maxNumber) { maxNumber = number; } } a. the largest of ten random numbers from 100 to 1000 b. the largest of ten random numbers from 0 to 99 c. the largest of eleven random numbers from 100 to 1000 d. the largest of eleven random numbers from 0 to 99 2 points Question 16 How many lines are printed on the console when the following for loop is executed? for (int i = 2; i < 10; i++) { System.out.println(i); } a. 7 b. 9 c. 8 d. 10 2 points Question 17 Code example 4-1 int limit = 0; for (int i = 10; i >= limit; i -= 2) { for (int j = i; j <= 1; j++) { System.out.println("In inner for loop"); } System.out.println("In outer for loop"); } (Refer to code example 4-1.) How many times does In outer for loop print to the console? a. 11 b. 8 c. 10 d. 6 2 points Question 18 What is the value of x after the following statements are executed? int x = 5; switch(x) { case 5: x += 2; case 6: x++; break; default: x *= 2; break; } a. 7 b. 10 c. 8 d. 6 e. 16 2 points Question 19 The practice of coding a statement within another statement is called ____________. 2 points Question 20 Output example 5-1 Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:818) at java.util.Scanner.next(Scanner.java:1420) at java.util.Scanner.nextDouble(Scanner.java:2324) at FutureValueApp.main(FutureValueApp.java:17) (Refer to output example 5-1.) What is this output called? a. a method log b. an exception handler c. an exception hierarchy d. a stack trace 2 points Question 21 The process of checking a value to be sure that its not less than a minimum value and not greater than a maximum value is called ____________________. 2 points Question 22 When an error occurs during the execution of a method, the method ____________ an exception. 2 points Question 23 When a statement within a try block causes an exception, the remaining statements in the try block a. are executed before the statements in the catch block b. arent executed c. are executed after the statements in the catch block 2 points Question 24 When you call a method, you must include the ____________ required by the method. 2 points Question 25 To install an application thats likely to be updated regularly on all computers on a companys network, you probably want to use _____________________ to deploy the application. 2 points Question 26 When a breakpoint is reached while youre debugging an application with an IDE, you can view the values of the available __________________. 2 points Question 27 To make it easier for your users to run an executable JAR file for a console application, you can create a script that uses the ____________ command to start the application. 2 points Question 28 You must use the this keyword a. to pass a primitive type by value to a method b. to pass an object by reference to a method c. to refer to an instance variable from a method when it has the same name as a method parameter d. to refer to any method thats called within a user-defined class 2 points Question 29 When you call the equals() method in the String class without knowing how its coded, youre taking advantage of what object-oriented concept? a. inheritance b. modeling c. instantiation d. encapsulation 2 points Question 30 In which of the following situations would it make most sense to code a static method rather than a regular method in a class that defines a bank account? a. a method that posts a transaction b. a method that changes the annual interest rate for all bank accounts c. a method that returns the bank account balance d. a method that calculates the number of deposits made in an account 2 points Question 31 Which of the following is true about a method that has this declaration? public Employee getDepartmentManager(){...} a. its only accessible within its class b. it uses an Employee object as a parameter c. its located in the Employee class d. it returns an object of the Employee class 2 points Question 32 Which method is an example of overloading the method that follows? public int parseNumber(String numberString){...} a. public int parseNumber(String numberString, String entry){...} b. public double parseNumber(String numberString){...} c. public int parseNumber(String num){...} 2 points Question 33 What class or classes is a method that is declared protected available to? a. All classes in all packages b. The current class c. All classes in the same package and to subclasses d. All classes in the same package 2 points Question 34 To call a constructor or method of a superclass from a subclass, you use the ____________ keyword. 2 points Question 35 When a subclass that is not declared as abstract inherits an abstract class, a. it must override all of the methods in the abstract class b. it must override all of the abstract methods in the abstract class c. it must override all of the final methods in the abstract class d. it cant override any of the methods in the abstract class 2 points Question 36 A class that cant be inherited by another class is called a/an ____________ class. 2 points Question 37 With Java 8 and later, what keyword can you use to code a static method in an interface? a. the regular keyword b. the static keyword c. the nonstatic keyword d. the default keyword 2 points Question 38 The clone method of the Object class may not work properly with a class that contains ____________ objects. 2 points Question 39 A class that ______________ an interface must contain methods for all abstract methods in the interface. Otherwise, the class must be declared as abstract. 2 points Question 40 If a class implements one interface, what keyword do you use in the class declaraction to specify that interface? a. extends b. inherits c. interface d. implements 2 points Question 41 Directory structure 10-1 invoice InvoiceApp.java murach business Invoice.java LineItem.java Product.java database ProductDB.java presentation Validator.java (Refer to directory structure 10-1.) If the directory structure is for an Invoice application that uses packages, what is the name of the package that contains the Invoice.java class? a. business b. business.murach c. murach.business d. invoice.murach.business 2 points Question 42 In what type of file is javadoc documentation stored? a. java file b. txt file c. class file d. html file 2 points Question 43 Which of the following is a benefit of using javadoc comments? a. They show other programmers how to code a class. b. They make it easy for other programmers to learn about your class. c. They make your classes easier to debug. d. They allow other programmers to view the source code for your class. 2 points Question 44 When using an IDE, what must you do to use a class thats stored in a library? a. Nothing. Classes in libraries are automatically available. b. Code an import statement for the class. c. Add the library to your project. d. Both b and c. 2 points Question 45 To view javadoc documentation, you use a ________________. 2 points Question 46 What is the value of kilos[1] after the code that follows is executed? double[] kilos = {200, 100, 48, 59, 72}; for (int i = 0; i < kilos.length; i++) { kilos[i] *= 2.2; } a. 440.0 b. 220.0 c. 100.0 d. 200.0 2 points Question 47 What is the value of nums[2] after the following statements are executed? int[] values = {2, 3, 5, 7, 9}; int[] nums = values; values[2] = 1; a. 3 b. 0 c. 5 d. 1 2 points Question 48 When you use an enhanced for loop with an array, you dont need to use a/an ________________ variable to iterate through the elements of the array. 2 points Question 49 To refer to an element in an array you use a/an ____________. 2 points Question 50 What is the value of names[4] in the following array? String[] names = {"Jeff", "Dan", "Sally", "Jill", "Allie"}; a. name[4] doesnt exist b. Jill c. Sally d. Allie

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Postgresql 16 Administration Cookbook Solve Real World Database Administration Challenges With 180+ Practical Recipes And Best Practices

Authors: Gianni Ciolli ,Boriss Mejias ,Jimmy Angelakos ,Vibhor Kumar ,Simon Riggs

1st Edition

1835460585, 978-1835460580

More Books

Students also viewed these Databases questions