






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







translates high-level language program into machine language program. - ANSWERA compiler Java ___________ can run from a Web browser - ANSWERapplets ________ is interpreted. - ANSWERJava ______ is a technical definition of the language that includes the syntax and semantics of the Java programming language. - ANSWER contains predefined classes and interfaces for developing Java programs. - ANSWERAPI _____ consists of a set of separate programs for developing and testing Java programs, each of which is invoked from a command line. - ANSWERJava JDK ___ provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface. - ANSWERJava IDE The main method header is written as: - ANSWERpublic static void main(String[] args) Which of the following statements is correct? - ANSWEREvery statement in a program must end with a semicolon. Which of the following statements is correct to display Welcome to Java on the console? - ANSWERSystem.out.println("Welcome to Java"); System.out.print("Welcome to Java"); The JDK command to compile a class in the file Test.java is - ANSWERjavac Test.java
Which JDK command is correct to run a Java application in ByteCode.class? - ANSWERjava ByteCode.class Java compiler translates Java source code into ____ - ANSWERA. Java bytecode _____ is a software that interprets Java bytecode - ANSWERJava virtual machine Suppose you define a Java class as follows: public class Test { } In order to compile this program, the source code should be stored in a file named - ANSWERTest.java The extension name of a Java bytecode file is - ANSWER.class The extension name of a Java source code file is - ANSWER.java Which of the following lines is not a Java comment? A. /** comments / B. // comments C. -- comments D. / comments */ E. ** comments ** - ANSWER-- comments ** comments ** the following are the reserved words: - ANSWERA. public B. static C. void
Which of the following code displays the area of a circle if the radius is positive. - ANSWERif (radius >
What is the syntax error in the program below? public class MyError { public static void method(String[] args) { System.out.print("Hello, Goodbye"); } } - ANSWERThe name of the method must be main What is the problem with the following algorithm? Repeat a number of times Add sales amount to total sales. - ANSWERThe algorithm is ambiguous because it does not specify how many times to repeat the Add statement Select a pseudocode statement to complete the following algorithm, which computes the cost of a shipment. Shipping costs depend on the weight of the item being shipped. The cost is $10 if the item weighs up to five pounds. For heavier items, the cost is $10 plus $2 for each pound in excess of five. cost = $ If weight is greater than five pounds
extra charge = $2 x number of excess pounds Add extra charge to cost. - ANSWERnumber of excess pounds = weight - 5 Which of the following represents a correct way to declare and initialize a variable named counter? - ANSWERint counter = 1; Which of the following is NOT a valid number literal of type double? - ANSWER2.5E
2,503.50 x
System.out.print(destination.substring(7, 12)); - ANSWERState What output does this while loop generate? int number = 1; while (number <= 5) { int value = number * 3; System.out.print(value + ", "); number++; } - ANSWER3, 6, 9, 12, 15, Trace the following code, assuming that both first and second begin with a value of 1. How many values are printed? while (second <= 10) { System.out.println (second); int temp = first + second; first = second; second = temp; } - ANSWER Second First Temp 1 1 2 2 2 3 3 3 5 5 5 8 8 8 13 What output does this for loop generate? for (int j = 0; j < 5; j++) {
int value = j * 2; System.out.print(value + ", "); - ANSWER0, 2, 4, 6, 8, Insert the missing condition in the following code fragment. The code is intended to add 5 to variable shippingCost if the value of variable weight is at least 10. if (__________) { shippingCost = shippingCost + 5; } - ANSWERweight >= 10 Insert the missing condition in the following code fragment. The code is intended to increment variable count if the String variable vehicle contains the value "sedan". if (__________) { count++; } - ANSWERvehicle.equals("sedan") Assuming that variable base has a value of 5 and variable height has a value of 12, what output is generated by the code segment below? if (base >= height / 2) { System.out.print(base); } else { System.out.print(height); } System.out.print(" " + (base * height) / 2); - ANSWER12 30
} - ANSWERMath.random() > 0. In the statement below, the value stored in variable temp is called _________________. double temp = Math.pow(3, 4); - ANSWERreturn value What value is returned by the method call Math.pow(1 + 2, 3)? - ANSWER27. Insert the missing statement in the following code fragment. The method is designed to compute the area of a circle with the radius given as argument. public static double circleArea(double radius) { double area = Math.PI * radius * radius;
} - ANSWERreturn area; Which of the following is the correct way to create a Scanner object to read text from an input file data.txt? - ANSWERFile theFile = new File("data.txt"); Scanner inputFile = new Scanner(theFile); Which of the following is the correct way to create a PrintWriter object to write text to an output file results.txt? - ANSWERPrintWriter outputFile = new PrintWriter("results.txt");