Details of this Paper

Java mcq




switch (val);case 1;System.out.print("P");case 2;case 3;System.out.print("Q");break;case 4;System.out.print("R");default;System.out.print("S");What is the output?;A.;PQS;B.;PQ;C.;S;D.;P;4 points;Question 2;How many times will "hello" be printed by the following;for (int i = 0, i < 10, i++);System.out.println("hello");A.;9;B.;0;C.;11;D.;10;4 points;Question 3;When writing a subclass, which of all of the following are true?;A.;You can override methods of the superclass;B.;You can inherit methods from the superclass;C.;You can define new methods in the subclass;D.;All of the above;4 points;Question 4;Select the best answer.;Local variables are destroyed when;A.;the constructor runs;B.;you explicitly delete them;C.;the object is no longer in use;D.;the method ends;4 points;Question 5;Which of the following is a valid constructor method header for a class named Car?;A.;Public Class Car;B.;public car(String model);C.;public class Car(String model);D.;public Car(String model);4 points;Question 6;For the code;int m = 0;while (m++ < 2);System.out.print(m + " ");What is the output?;A.;0 1 2;B.;1 2;C.;1;D.;0 1;4 points;Question 7;Remember that the % operator evaluates to the remainder after integer division e.g. 8 % 4 is 0, 11 % 4 is 3. What is the value of x after the following?;int x = 0;for (int i = 1, i = 4);System.out.println("Test A");else if (val > 9);System.out.println("Test B");else;System.out. println("Test C");Which one of the alternatives below will result in "Test C" being printed;A.;val is 4;B.;no values of val will do this;C.;val < 4;D.;val between 4 and 9;4 points;Question 11;Given;int quantity = 3;double value = 7.52;String number = "one;Which of all of the following are valid assignments?;A.;quantity = value;B.;quantity = (int)value;C.;value = quantity;D.;quantity = (double)value;E.;quantity = number;F.;Both B and C;4 points;Question 12;Select the best answer.;A(n) ____ can add instance variables and methods to an existing class.;A.;subclass;B.;polymorphism;C.;superclass;D.;constructor;4 points;Question 13;What is the error in the following code fragment?;double data[] = new double[20];data[20] = 15.25;A.;Out-of-bounds error;B.;Data not initialized;C.;A two-dimensional array is required;D.;A cast is required;4 points;Question 14;If you know that your loop must iterate at least one time, it is recommended that you use a _________ loop;A.;do _ while;B.;repeat;C.;for;D.;while;4 points;Question 15;Multiplying an int (such as 5) by a double (such as 0.1) gives;A.;an exception is thrown;B.;an int;C.;an error;D.;a double;4 points;Question 16;After executing this code segment;double v1 = 2000.0;double v2 = v1;v2 = v2 + 500.0;What will be the value of v1?;A.;Unknown;B.;2000.0;C.;2500.0;D.;0.0;4 points;Question 17;Which of the following indicates that a method does not return a value?;A.;double;B.;static;C.;void;D.;public;4 points;Question 18;Where an inherited method is overridden, the type of the actual object, not the type of the reference to the object is used to determine which method to call?;True;False;4 points;Question 19;The compiler will generate an error if the same name but different signature is used for more than one method or constructor.;True;False;4 points;Question 20;Given this code fragment;int x = 5, y = 6, z = 7;foo(x, y, z);System.out.println(x + ", " + y + ", " + z);public void foo(int a, int b, int c);a = a + 3;b = a + c;c = c + b;What is the output?;A.;5, 6, 7;B.;8, 12, 13;C.;2, 0, 4;D.;8, 15, 22;4 points;Question 21;javadoc comments begin and end with;A.;// and //;B.;/* and */;C.;/** and */;D.;/@ and @/;4 points;Question 22;When using the BlueJ debugger, a class must be compiled before you can set a break point in it?;True;False;4 points;Question 23;Which of the following are Java naming conventions?;#1: Classes start with an uppercase letter;#2: Methods start with an uppercase letter;#3: Object start with a lowercase letter;#4: Objects start with an uppercase letter;#5: Classes start with a lowercase letter;#6: Methods start with a lowercase letter;A.;#1, #3 and #6;B.;#4, #5 and #6;C.;#1, #2 and #4;D.;#3, #5 and #6;4 points;Question 24;Given the array;double cost[] = new double[5];How would you access the last element of the array?;A.;cost.get(4);B.;cost[4];C.;cost.get[5];D.;cost[5];4 points;Question 25;In a program, you create an object of a class using the keyword ____.;A.;abstract;B.;extends;C.;create;D.;new;4 points;Save and Submit;Click Save and Submit to save and submit. Click Save All Answers to save all answers.


Paper#68244 | Written in 18-Jul-2015

Price : $27