1) Because Java byte code is the same on all computers, compiled Java programs:
ID: 3762974 • Letter: 1
Question
1) Because Java byte code is the same on all computers, compiled Java programs: A) Must be re-compiled for each different machine it is run on B) Cannot run on Linux systems C) Are non-existent D) Are highly portable 2) This is a cross between human language and a programming language. A) Pseudocode B) Java C) The Java Virtual Machine D) The compiler 3) The data contained in an object is known as: A) Methods B) Attributes C) Classes D) Atriums 4) Which of the following is NOT part of the programming process? A) Design B) Testing C) Debugging D) All the above are parts of the programming process. 5) A Java program must have at least one of these: A) Class definition B) Variable C) Comment D) System.out.println(); statement 6) In Java, the beginning of a comment is marked with: A) // B) "" C) ; D) # 7) In Java, ________ must be declared before they can be used. A) variables B) literals C) key words D) comments 8) If the following Java statements are executed, what will be displayed? System.out.println("The top three winners are "); System.out.print("Jody, the Giant "); System.out.print("Buffy, the Barbarian"); System.out.println("Adelle, the Alligator"); A) The top three winners are Jody, the Giant Buffy, the Barbarian Adelle, the Alligator B) The top three winners are Jody, the Giant Buffy, the BarbarianAdelle, the Alligator C) The top three winners are Jody, the Giant Buffy, the BarbarianAdelle, and the Albino D) The top three winners are Jody, the Giant Buffy, the BarbarianAdelle, the Alligator 9) What would be printed out as a result of the following code? System.out.println("The quick brown fox" + "jumped over the " "slow moving hen."); A) The quick brown fox jumped over the slow moving hen. B) The quick brown fox jumped over the slow moving hen. C) The quick brown fox jumped over the slow moving hen. D) Nothing. This is an error. 10) In Java, it is standard practice to capitalize the first letter of: A) Class names B) Variable names C) Key words D) Literals 11) Which of the following is NOT a primitive data type? A) short B) long C) float D) String 12) What is the result of the following expression? 10 + 5 * 3 - 20 A) -5 B) 5 C) 25 D) -50 13) What will be displayed as a result of executing the following code? int x = 5, y = 20; x += 32; y /= 4; System.out.println("x = " + x + ", y = " + y); A) x = 32, y = 4 B) x = 9, y = 52 C) x = 37, y = 5 D) x = 160, y = 80 14) In the following Java statement what value is stored in the variable name? String name = "John Doe"; A) John Doe B) The memory address where "John Doe" is located C) name D) The memory address where name is located 15) What will be displayed as a result of executing the following code? public class test { public static void main(String[] args) { int value1 = 9; System.out.println(value1); int value2 = 45; System.out.println(value2); System.out.println(value3); value = 16; } } A) 9 45 16 B) 94516 C) 9 45 16 D) Nothing, this is an error. 16) What would be displayed as a result of the following code? int x = 578; System.out.print("There are " + x + 5 + " " + "hens in the hen house."); A) There are 583 hens in the hen house. B) There are 5785 hens in the hen house. C) There are x5 hens in the hen house. D) There are 5785 hens in the hen house. 17) What will be displayed after the following statements have been executed? int x = 15, y = 20, z = 32; x += 12; y /= 6; z -= 14; System.out.println("x = " + x + ", y = " + y + ", z = " +z); A) x = 27, y = 3.333, z = 18 B) x = 27, y = 2, z = 18 C) x = 27, y = 3, z = 18 D) x = 37, y = 14, z = 4 18) Which Scanner class method reads an int? A) readInt() B) nextInt() C) getInt() D) read_int() 19) Which Scanner class method reads a String? A) readString() B) nextString() C) getString() D) nextLine() 20) What will be the values of ans, x, and y after the following statements are executed? int ans = 35, x = 50, y =50; if ( x >= y) { ans = x + 10; x -=y; } else { ans = y + 10; y += x; } A) ans = 60, x = 50, y =100 B) ans = 60, x =0, y =50 C) ans = 45, x = 50, y = 0 D) ans = 45, x = 50, y = 50 21) What will be the value of bonus after the following code is executed? int bonus, sales = 10000; if (sales < 5000) bonus = 200; else if (sales < 7500) bonus = 500; else if (sales < 10000) bonus = 750; else if (sales < 20000) bonus = 1000; else bonus = 1250; A) 200 B) 500 C) 750 D) 1000 E) 1250 Programming Question ( 20 points) Write a complete Java program that will allow the user to enter his name , ( First name and Last name), and his age in years. Then subtract user’s age from 100 and display the following message on the monitor: Mr/Mrs First name Last Name you have xx years to live!! If user’s age is less than 65 subtract user’s age from 65 and display the following message Mr.Mrs First Name Last Name you can retire in xx years If user’s age is greater than 65 the program should display You should have retired xx years ago
Explanation / Answer
Grate Answer:
++++++++++++
Java bytecode is the instruction set of the Java virtual machine. Each bytecode is composed by one, or in some cases two, bytes that represent the instruction (opcode), along with zero or more bytes for passing parameters.
A Java compiler might translate the Java code above into byte code as follows, assuming the above was put in a method:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.