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

13) Of the following types, which one cannot store a numeric value? A) int B) by

ID: 3590071 • Letter: 1

Question


13) Of the following types, which one cannot store a numeric value? A) int B) byte C) float D) char E) all of these can store numeric values 14) What value will z have if we execute the following assignment statement? float z = 5 / 10; A) z will equal 0.0 B) z will equal 0.5 C) z will equal 5.0 D) z will equal 0.05 E) none of the above, a run-time error arises because z is a float and 5/10 is an int 15) What is output with the statement System.out.println("+xty); if x and y are int values where x-10 and y-5? A) 15 B) 105 C) 105 D) xty E) An error since neither x nor y is a String 16) If you want to store into the String name the value "George Bush", you would do which statement? A) String name "George Bush"; B) String name new String"George Bush"): E) " + "Bush"; D) String name = new String("George" + " " + "Bush"); +" Any of the above would work 17) Provide three examples of code using assignment statements where one assignment statement would result in a syntax error, one would result in a logical error, and one would result in a run-time error. 18) Write a Java program that will display the following three lines when it is run: public static void main(String[ ] args) 19) In order to create a constant, you would use which of the following Java reserved words? E) class A) private B) staticC) in order to create a constant, you would use which of the following Java reserved words? A) private B)tC)int D) final 20) In D) final E) class 21.) Assume that x, y, and z are all integers (int) equal to 50, 20, and 6 respectively What is the result of x/y /z A)0 B) 12 C) 16 D) A syntax error as this is syntactically invalid 22) When executing a program, the processor reads cach program instruction from A) secondary memory (storage) B) the Internet C) registers stored in the processor D) main memory B) 24. Which one is a valid declaration of a boolean? A. boolean bl 1; B. boolean b2 = "false"; C. boolean b3-false; D. boolean b4 "true 25). 8. What is the output of this program? class increment public static void main( String argsI) { int g = 3; System.out.print(++g *8); A. 25 B. 24 C. 32 D. 33

Explanation / Answer

13)

Answer : Option 'e' (All of these can store numeric values)
Explanation : All the above data types can store a numeric value. Eg int a=10 , float b=10 etc


14)

Answer : Option 'a' (z will equal 0.0)
Explanation : Since, 5 and 10 integers, integer division takes place, hence the result would be 0. Since, the variable is of type float, it would be converted to floating point number and hence the result would be 0.0

15)

Answer : Option 'b' (105)
Explanation : "+x+y will be executed as ("+x)+y. Hence, the result of "+x would be string "10" and then, x+y would be "10"+5 since "10" is of type string , then string conactenation takes place and the output would be "105".

16)

Answer : Option 'e' (Any of the above would work)
Explanation : All are valid statements

17)

Syntax Error : int a=10 (ERROR : ';' is missing)
Logical Error : int a = true; (ERROR : incompatible types)
Runtime Error : int a = 5/0 (ERROR : division by 0 throws an exception)

18)

public class PrintStars{

public static void main(String args[])
{
  
System.out.println("*");
System.out.println("* * *");
System.out.println("* * * * *");
}
}

19)

Answer : Option 'd' (final)
Explanation : "final" keyword is used to create a constant and it's value cannot be changed

20)

Answer : Option 'd' (final)
Explanation : "final" keyword is used to create a constant and it's value cannot be changed

21)

Answer: Option 'a' (0)

22)
Answer : Option 'd'
Explanation : The program is executed in thee main memory(RAM).

24)
Answer : Option 'c' (boolean b3= false;)

25)
Answer : Option 'c' (32)
Explanation : ++g is preincrement operator and hence ++g evaluates to ++3 =4 and then 4*8 happens. Hence answer = 32.

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