1) What will be the value of x after the following code is executed? int x = 10; while (x < 100) ( A) 90 B) 100 C) 110 D

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1) What will be the value of x after the following code is executed? int x = 10; while (x < 100) ( A) 90 B) 100 C) 110 D

Post by answerhappygod »

1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 1
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 1 (20.4 KiB) Viewed 20 times
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 2
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 2 (34.52 KiB) Viewed 20 times
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 3
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 3 (36 KiB) Viewed 20 times
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 4
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 4 (37.49 KiB) Viewed 20 times
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 5
1 What Will Be The Value Of X After The Following Code Is Executed Int X 10 While X 100 A 90 B 100 C 110 D 5 (43.37 KiB) Viewed 20 times
1) What will be the value of x after the following code is executed? int x = 10; while (x < 100) ( A) 90 B) 100 C) 110 D) This is an infinite loop x += 10; } 2) What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x + y; } A) 90 B) 110 C) 210 D) This is an infinite loop 3) How many times will the following do-while loop be executed? int x = 11; do { A) 0 B) 1 C) 4 D) 5 x += 20; } while (x > 100);
4) What will be the value of x after the following code is executed? int x = 10; do (x *= 20;} while (x <5); A) 10 B) 200 C) This is an infinite loop. D) The loop will not be executed, the initial value of x > 5. 5) Before entering a loop to compute a running total, the program should first A) Read all the values into main memory B) Set the accumulator where the total will be kept to an initial value, usually zero C) Know exactly how many values there are to total D) Set all variables to zero 6) Any method that calls a method that uses a File object should have a throws FileNotFoundException clause in its header. A) True B) False 7) What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; y += 20; } A) 90 B) 110 C) 130 D) 210 8) In all but rare cases, loops must contain within themselves A) Arithmetic statements B) if statements C) A way to terminate D) Nested loops
9) What will be the value of x after the following code is executed? int x = 10; for (int y = 5; y < 20; y +=5) x += y; A) 40 B) 25 C) 30 D) Invalid for statement 10) What is wrong with the following method call? display Value (double x); A) There is nothing wrong with the statement B) display Value will not accept a parameter C) Do not include the data type in the method call D) x should be a string 11) Which of the following would be a valid method call for the following method? public static void showProduct(double num1, int num2) { double product; product = num1* num2; System.out.println("The product is " + product); } A) showProduct(5, 40.1); B) showProduct(10.0, 4.6); C) showProduct(10, 4.5); D) showProduct(3.3,55); 12) What will be returned from the following method? public static int MethodA() { double a = 8.5+ 9.5; return a; } A) 18.0 B) 18 C) 8 D) This is an error
13. In the following code, what values could be read into number to terminate the while loop? Scanner keyboard-new Scanner(System.in); System.out.print("Enter a number: "); int number = keyboard.nextInt(); while (number<100 && number> 500) 1 System.out.print("Enter another number: "); number = keyboard.nextInt(); } a) Numbers less than 100 or greater than 500 b) Numbers in the range 100-499 c) Numbers in the range 100-500 d) The boolean condition can never be true 14. If method A calls method B, and method B calls method C, and method C calls method D, when method D finishes, what happens? Control is returned to method A. >>Control is returned to method B. Control is returned to method C. The program terminates. 15. When an object, such as a String, is passed as an argument, it is: actually a reference to the object that is passed passed by value like any other parameter value encrypted necessary to know exactly how long the string is when writing the program 16. The lifetime of a method's local variable is: the duration of the program the duration of the class to which the method belongs the duration of the method that called the local variable's method only while the method is executing 17. Local variables: are hidden from other methods may have the same name as local variables in other methods lose the values stored in them between calls to the method in which the variable is declared 4)All of the above
18. You can use this method to determine whether a file exists. a) The Scanner class's exists method b) The File class's exists method c) The File class's canOpen method d) The Print Writer class's fileExists method 19. Only constants and variables may be passed as arguments to methods. a) True b) False 20. No statement outside the method in which a parameter variable is declared can access the parameter by its name. a) True b) False Convert the following for loop to a while loop: for (int x = 50; x > 0; x--) { } System.out.println(x +" seconds to go.");
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply