All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Ask a Question
Search
Search
Sign In
Register
study help
computer science
java programming 8th
Questions and Answers of
Java Programming 8th
Given the following declaration: char c = ‘A’; What is the simplest way to convert the character value in c to an int? Select the one correct answer. (a) int i = c; (b) int i = (int) c; (c) int i
What will be the result of compiling and running the following program?Select the one correct answer. (a) The program will fail to compile, since the compiler will report that the variable c in the
What will be the result of compiling and running the following program?Select the one correct answer.(a) The program will fail to compile.(b) The program will print mouse at runtime. (c) The program
Which of the following expressions will be evaluated using floating-point arithmetic?Select the three correct answers.(a) 2.0 * 3.0(b) 2 * 3(c) 2/3 + 5/7(d) 2.4 + 1.6(e) 0x10 * 1L * 300.0
What is the value of the expression (1 / 2 + 3 / 2 + 0.1)?Select the one correct answer.(a) 1(b) 1.1(c) 1.6(d) 2(e) 2.1
What will be the result of compiling and running the following program?Select the one correct answer. (a) The program will not compile. (b) When run, the program will print 28. (c) When run, the
Which of the following expressions are valid?Select the three correct answers.(a) (- 1 -)(b) (+ + 1)(c) (+-+-+-1)(d) (—1)(e) (1 * * 1)(f) (- -1)
What is the value of evaluating the following expression: (- -1-3 * 10 / 5- 1)?Select the one correct answer.(a) –8(b) –6(c) 7(d) 8(e) 10(f) None of the above
Which of these assignments are valid?Select the four correct answers.(a) short s = 12;(b) long l = 012;(c) int other = (int) true;(d) float f = -123;(e) double d = 0x12345678;
Which statements are true?Select the three correct answers.(a) The expression (1 + 2 + "3") evaluates to the string "33".(b) The expression ("1" + 2 + 3) evaluates to the string "15".(c) The
What happens when you try to compile and run the following program?Select the one correct answer.(a) The program will not compile, because of errors in the expression at (1).(b) The program will
Which is the first line that will cause a compile-time error in the following program?Select the one correct answer.(a) (1)(b) (2)(c) (3)(d) (4)(e) (5)(f) None of the above. The compiler will not
What is the result of compiling and running the following program?Select the one correct answer.(a) The program will not compile, because a byte value cannot be assigned to an int variable without
What will be the result of compiling and running the following program?Select the one correct answer.(a) 13 (b) 14 (c) 20 (d) 21 (e) 24 public class EvaluationOrder { public static void main(String
Which of the following expressions evaluate to true?Select the two correct answers.(a) (false | true)(b) (null != null)(c) (4
Which of the following statements are true?Select the two correct answers.(a) The remainder operator % can be used only with integral operands.(b) Short-circuit evaluation occurs with boolean logical
Which statements are true about the lines of output printed by the following program?Select the three correct answers.(a) All lines printed are the same.(b) At least one line contains false.(c) At
What is the result of running the following program?Select the one correct answer.(a) When run, the program throws an ArrayIndexOutOfBoundsException.(b) When run, the program will print 9 9 6.(c)
Which statements are true about the output from the following program?Select the two correct answers.(a) The first digit printed is 1.(b) The first digit printed is 2.(c) The first digit printed is
Which of the following are not operators in Java?Select the two correct answers.(a) %(b) &&(c) %=(d) &&= (e)
Which statements when inserted at (1) will not result in a compile-time error?Select the three correct answers.(a) int result1 = i (b) int result2 = i (c) Number number = i (d) System.out.println(i
Which statements are true about the following code?Select the one correct answer.(a) The program will not compile.(b) When run, the program throws an ArithmeticException at runtime.(c) When run, the
What will be the result of attempting to compile and run the following class?Select the one correct answer.(a) The code will fail to compile because the syntax of the if statement is incorrect.(b)
Which of the following statements are true?Select the three correct answers.(a) The condition in an if statement can have method calls.(b) If a and b are of type boolean or Boolean, the expression (a
What, if anything, is wrong with the following code?Select the one correct answer.(a) The variable x does not have the right type for a switch expression.(b) The case label 0 must precede the case
What will be the result of attempting to compile and run the following program?Select the one correct answer.(a) The code will fail to compile because of the case label value 2 * iLoc.(b) The code
What will be the result of attempting to compile and run the following program?Select the one correct answer.(a) The code will fail to compile because the type of the switch expression is not
Which case label declaration can be inserted at (1) so that the following program will compile, run, and print Hi, TomTom!? Select the four correct answers.(a) case "TomTom":(b) case TOM1 + TOM1:(c)
What will be the result of attempting to compile and run the following code?Select the one correct answer.(a) The code will fail to compile because b is an invalid condition for the dowhile
What will be the output when running the following program?Select the two correct answers.(a) The first number printed will be 9.(b) The first number printed will be 10.(c) The first number printed
Which of the following for statements is valid?Select the one correct answer.(a) int j = 10; for (int i = 0, j += 90; i < j; i++) { j--; }(b) for (int i = 10; i = 0; i--) {}(c) for (int i = 0, j =
What will be the result of attempting to compile and run the following program?Select the one correct answer.(a) The code will fail to compile because of errors in the for loop at (1).(b) The code
Which of the following statements are valid when occurring on their own?Select the three correct answers.(a) while () break;(b) do { break; } while (true);(c) if (true) { break; }(d) switch (1) {
Given the following code fragment, which of the following lines will be a part of the output?Select the two correct answers.(a) i=1, j=0 (b) i=0, j=1(c) i=1, j=2 (d) i=2, j=1 (e) i=2, j=2 (f) i=3,
What will be the result of attempting to compile and run the following code?Select the one correct answer.(a) The code will fail to compile because of an illegal switch expression in the switch
Which declarations, when inserted at (1), will result in the program compiling and printing 90 at runtime?Select the two correct answers.(a) Object[] nums = {20, 30, 40};(b) Number[] nums = {20, 30,
Which method declarations, when inserted at (1), will result in the program compiling and printing 90 when run?Select the two correct answers.(a)(b)(c)(d)(e) public class RQ400A30 ( public static
Which digits, and in which order, will be printed when the following program is run?Select the one correct answer.(a) The program will only print 5.(b) The program will only print 1 and 4, in that
Given the following program, which statements are true?Select the two correct answers.(a) If run with no arguments, the program will produce no output.(b) If run with no arguments, the program will
Which of the following statements are true?Select the two correct answers.(a) If an exception is not caught in a method, the method will terminate and normal execution will resume.(b) An overriding
Which digits, and in which order, will be printed when the following program is run?Select the one correct answer.(a) The program will print 2 and throw InterruptedException.(b) The program will
What is wrong with the following code?Select the one correct answer.(a) The main() method must declare that it throws B.(b) The finally clause must follow the catch clause in the main() method.(c)
Which throws clause should be inserted at (1) for the overriding method compute() in the following code so that the code will compile without errors?Select the one correct answer.(a) No throws clause
Which of the following statements are true?Select the two correct answers.(a) In Java, the extends clause is used to specify the inheritance relationship.(b) The subclass of a non-abstract class can
Which of the following statements are true?Select the two correct answers.(a) A class can be extended by only one class.(b) Every Java object has a public method named equals.(c) Every Java object
Given the following classes and declarations, which statements are true?Select the three correct answers.(a) The Bar class is a subclass of Foo.(b) The statement b.f(); is legal.(c) The statement a.j
Given classes A, B, and C, where B extends A, and C extends B, and where all classes implement the instance method void doIt(), how can the doIt()method in A be called from an instance method in
What would be the result of compiling and running the following program?Select the one correct answer.(a) The code will fail to compile.(b) The code will compile, but throw an exception at
Which is the simplest expression that can be inserted at (1), so that the program prints the value of the text field from the Message class?Select the one correct answer.(a) text (b) Message.text (c)
What would be the result of compiling and running the following program?Select the one correct answer.(a) The code will fail to compile.(b) The code will compile, and print |Toyota|Volvo|12345|54321|
Which constructors can be inserted at (1) in MySub without causing a compiletime error?Select the one correct answer.(a) MySub() {}(b) MySub(int count) { this.count = count; }(c) MySub(int count) {
Which of the following statements is true?Select the one correct answer.(a) A super() or this() call must always be provided explicitly as the first statement in the body of a constructor.(b) If both
What will the following program print when run?Select the one correct answer.(a) It will just print Test.(b) It will print Test followed by Test.(c) It will print 123 followed by Test.(d) It will
Which of the following statements about interfaces are true?Select the two correct answers.(a) Interfaces allow multiple implementation inheritance.(b) Interfaces can be extended by any number of
Which modifiers can methods declared in a top-level interface specify?Select the four correct answers.(a) public(b) protected(c) private(d) default(e) abstract(f) static(g) final
Which modifiers are implicitly implied for interface variables?Select the three correct answers.(a) public(b) protected(c) private(d) default(e) abstract(f) static(g) final
How many errors will the compiler report for the following code?Select the one correct answer.(a) No errors (b) 1 error(c) 2 errors (d) 3 errors (e) More than 3 errors public interface Vehicle {
Which method calls can be inserted at both (1) and (2), so that the following code will still compile?Select the two correct answers.(a) printSlogan();(b) co.printSlogan();(c) sl.printSlogan();(d)
Which method call can be inserted at both (1) and (2), so that the following code will still compile?Select the one correct answer.(a) printSlogan();(b) co.printSlogan();(c) sl.printSlogan();(d)
What will the following program print when compiled and run?Select the one correct answer.(a) The program will not compile.(b) true|true (c) true|false (d) false|true (e) false|false // File:
What will the following program print when compiled and run?Select the one correct answer.(a) The program will not compile.(b) The program will compile, and print true when run.(c) The program will
Which of these field declarations are legal within the body of an interface?Select the three correct answers.(a) public static int ANSWER = 42;(b) int ANSWER;(c) static final int ANSWER = 42;(d)
Which statements about the keywords extends and implements are true?Select the two correct answers.(a) The keyword extends is used to specify that an interface inherits from another interface.(b) The
Which statement is true about the following code?Select the one correct answer.(a) MyClass implements only Interface1; the implementation for void h() from Interface2 is missing.(b) The declarations
Which declaration can be inserted at (1) without resulting in a compile-time error?Select the two correct answers.(a) final double CIRCUMFERENCE = 2 * Math.PI * R;(b) int TOTAL = TOTAL + R + S;(c)
Which statement about the following program is true?Select the one correct answer.(a) The program will fail to compile because of the assignment at (1).(b) When run, the program will throw a
Which statements will cause a compile-time error in the following code?Select the two correct answers.(a) (1)(b) (2)(c) (3)(d) (4)(e) (5)(f) (6) public class MyClass { public static void
Given the following type and reference declarations, which assignment is legal?Select the one correct answer.(a) obj2 = obj1;(b) obj3 = obj1;(c) obj3 = obj2;(d) I1 a = obj2;(e) I1 b = obj3;(f) I2 c =
Given the following class and reference declarations, what can be said about the statement y = (Sub) x?Select the one correct answer.(a) It is illegal at compile time.(b) It is legal at compile time,
Given three classes A, B, and C, where B is a subclass of A, and C is a subclass of B, which one of these boolean expressions is true only when the reference o refers to an object of class B, and not
What will the following program print when run?Select the one correct answer.(a) The program will not print any letters.(b) ICD (c) IJD (d) IJCD (e) ID public class RQ07A100 { public static void
What is the result of compiling and running the following program?Select the one correct answer.(a) The program will not compile because of errors.(b) The program will compile, but throw an exception
What will be the result of compiling and running the following program?Select the one correct answer.(a) The program does not compile because of errors in one or more calls to the compute()
What will be the result of compiling and running the following program?Select the one correct answer.(a) The program will fail to compile.(b) The program will compile, but will throw a
What will be the result of compiling and running the following program?Select the one correct answer.(a) The program will fail to compile.(b) The program will compile, and print 0 when run.(c) The
Which statements about the following program are true?Select the three correct answers:(a) The code will fail to compile.(b) The code defines a Planet is-a Star relationship.(c) The code will fail to
Given the following code, which statement is true?Select the one correct answer:(a) The code will fail to compile.(b) The code defines a Planet has-a Star relationship.(c) The code will fail to
Which of the following statements is not true?Select the one correct answer.(a) Maximizing cohesion and minimizing coupling are the hallmarks of a welldesigned application.(b) Coupling is an inherent
What is the return type of the hashCode() method in the Object class?Select the one correct answer.(a) String(b) int(c) long(d) Object(e) Class
Which of the following statements is true?Select the one correct answer.(a) If the references x and y denote two different objects, the expression x.equals(y) is always false.(b) If the references x
Which exception can the clone() method of the Object class throw?Select the one correct answer.(a) CloneNotSupportedException(b) NotCloneableException(c) IllegalCloneException(d)
Which of the following are wrapper classes?Select the three correct answers.(a) java.lang.Void(b) java.lang.Int(c) java.lang.Boolean(d) java.lang.Long(e) java.lang.String
Which of the following classes do not extend the java.lang.Number class?Select the two correct answers.(a) java.lang.Float(b) java.lang.Byte(c) java.lang.Character(d) java.lang.Boolean(e)
Which of these classes define immutable objects?Select the three correct answers.(a) Character(b) Byte(c) Number(d) Short(e) Object
Which of these classes have a single-parameter constructor taking a string?Select the two correct answers.(a) Void(b) Integer(c) Boolean(d) Character(e) Object
Which of the wrapper classes have a booleanValue() method?Select the one correct answer (a) All wrapper classes (b) All wrapper classes except Void (c) All wrapper classes that also implement the
Which statements are true about wrapper classes?Select the two correct answers.(a) String is a wrapper class.(b) Double has a compareTo() method.(c) Character has a intValue() method.(d) Byte extends
What will the following program print when compiled and run?Select the one correct answer.(a) false|true|false|true (b) true|true|true|true (c) false|true|true|true (d) true|true|false|true (e) None
Which of the following operators cannot have an operand of type String?Select the two correct answers.(a) +(b) -(c) +=(d) .(e) &
Which expression will extract the substring "kap", given the following declaration:String str = “kakapo”;Select the one correct answer.(a) str.substring(2, 2)(b) str.substring(2, 3)(c)
What will be the result of attempting to compile and run the following code?Select the one correct answer.(a) The code will fail to compile because the expression str3.concat(str1)will not result in
Which statement about the trim() method of the String class is true?Select the one correct answer.(a) It returns a string where the leading whitespace of the original string has been removed.(b) It
Which of the following statements are true?Select the two correct answers.(a) String objects are immutable.(b) Subclasses of the String class can be mutable.(c) All wrapper classes are declared as
What will be the result of attempting to compile and run the following program?Select the one correct answer.(a) The program will fail to compile.(b) The program will print false false at runtime.(c)
Which of these parameter lists can be found in a constructor of the String class?Select the five correct answers.(a) ()(b) (int capacity)(c) (char[] data)(d) (String str)(e) (CharSequence cs)(f)
Which of the following methods is not defined in the String class?Select the one correct answer.(a) trim()(b) length()(c) concat(String)(d) hashCode()(e) reverse()
What will the following program print when run?Select the one correct answer.(a) The program will print false true.(b) The program will print false false.(c) The program will print true false.(d) The
What will the following program print when run?Select the one correct answer.(a) |WOW|(b) | W W|(c) |WO|(d) | W |(e) The program will fail to compile.(f) The program will compile, but throw an
What will be the result of attempting to compile and run the following program?Select the one correct answer.(a) The program will fail to compile.(b) The program will compile, but throw an exception
What will be the result of attempting to compile and run the following program?Select the one correct answer.(a) The code will fail to compile, because there is no method named setLength in the
Showing 1 - 100
of 332
1
2
3
4