Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Analyze the following code: int i = 3434: double d = 3434: System.out.printf(\"%

ID: 3857542 • Letter: A

Question

Analyze the following code: int i = 3434: double d = 3434: System.out.printf("%5.1f %5.1f", I, d): A) i is an integer, but the format specifier %5.1f specifies a format for double value. The code has an error. B) The code complies and runs fine to display 3434.0 3434.0 C) The code complies and runs fine to display 3434 3434.0 ____ To add 0.01 + 0.02 + .. + 1.00, what order should you use to add the numbers to get better accuracy? A) add 0.01, 0.02, .., 1.00 in this order to a sum variable whose initial value is 0. B) add 1.00, 0.99, 0.98, .., 0.02, 0.01 in this order to a sum variable whose initial value is 0. ____ (char)('a' + Math random() = ('z' = 'a' + 1))returns a random character ____ between 'b' and 'z' between 'a' and 'y' between 'b' and 'y' between 'a' and 'z' ___ Suppose int i = 5, which of the following can be used as an index for array double[] t = new double[100]? (Choose all that apply.) A) (int)(Math.random() = 100) B) i C) i + 6.5 D) Math.random() = 100 E) i + 10 ____ Suppose you wish to provide an accessor method for a Boolean property finished, what s9ignature of the method should be? Public Boolean getFinished() Public Boolean isFinished() Public Boolean isFinished() Public Boolean getFinished() ____ Assume StringBuilder strBuf is "ABCCEFC", after invoking ___, strBfr contains "ABTTEFT". strBfr.replace("C", "T") strBfr.replace("CC", "TT") strBfr.replace('C', 'T') strBfr.replace(2, 7, "TTEFT") strBfr.replace('C', "TT") ____ Which of the following statements are true? (Choose all that apply.) A method can be overridden in the same class. If a method overrides another method, these two methods must have the same signature. If a method overloads another method, these two methods must have the same signature. A method can be overloaded in the same class. _____ Analyze the following code: public class Test { public static void main (String[] args) { String s = new String("Welcome to java"): Object o = s: String d = (String)o: } } When casting o to s in String d = (String)o, the contents of o is changed. When casting o to s in String d = (String)o, the a new object is created. s, o, and d reference the same String object. When assigning s to o in Object o = s, a new object is created. _____ What is the output of the following code? char ch = 'F": if(ch > = 'A" && ch

Explanation / Answer

34)A

it compiles ...but run time exception will be caught.

35) A

so that no casting requires..

36)B

exception 'z'-'a'+1 means.. it will remove last character 'z'

37)B

we can use as double[5]

38)C

we must provide return status .. and isFinished() method is speaking name

39)A

replace character "C" with second parameter "T"

23)B,C,D are correct.

24)C

it has same reference

25)C

it isstright way ,,it print F

26)C

it will take space for first 4 character ..and then prints 123456

27)D

normally n iterations and extra for final checking statement (i<n) so n+1 steps.

28)C

normally n iterates and extra for final checking statement (i<n) so n+1 steps.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote