) Of the following types, which one cannot store a numeric value? A) int B) byte
ID: 3590070 • Letter: #
Question
) Of the following types, which one cannot store a numeric value? A) int B) byte C) loat D) char E)all of these can store numeric values 14) What valuc will z have if we execute the following assignment statcment? float z -$/ 10; A)zwill equal 0.0 B) z will equal 0.5 E) none of the above, a run-time error arises because z is a float and 5 /10 is an int C) z will equal 5.0 D) z will equal 0.OS 15) What is output with the statement System.out.println4xty) if x and y are i y-5? A) 15 B)105 C) 105 D) x+y E) An error since neither x mr y is a string nt values where x-10 and 16) If you want to store into the String name the value "Gcorge Bush", you would do which statement? A) String name "Goorge Bush: B) String name - new Stringt "George Bush" C) String name-"Gorge" + " " + "Bush". D) String name-new String("Garge" +--+"Bush, E) Any of the above would work 17) Provide in a syntax error, one would result in a logical error, and one would result in a run-time error. three examples of code using assignment statements where one assignment statement would result 18) Write a Java program that will display the following three lines when it is run: public statie void main Stringl J args) 19) In order to create a constant, you would use which of the following Java reserved words? A) private B) static C) int D) final E) class 20) In order to create a constant, you would use which of the following Java reserved words? A) private B) static C 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 C16 D) A syntax error as this is syntactically invalid 22) When executing a program, the processor reads each 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 b 1-1 ; B. boolean b-, 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 args) t int g 3 System.out.print(+tg 8) A. 25 B. 24 C. 32 D. 33Explanation / Answer
13) option D - char
14) option A - Z will equal 0, since 5/10 will result in integer division
15) option B - 105 , since ""+x+y will just do concatenation of the values
16) option E - Any of the above would work
17) double sum = 5;
int n = 0;
float a = 5;
//syntax error , assigning float value to int
n = a;
//runtime error, since n = 0, will cause runtime divisioon by error
double avg = sum / n;
//logic error
double rateOfInterest = 5;
double principal = 1000;
int years = 2;
double interest = rateOfInterest * principal * years; //logic error, should divide by 100
18)
public static void main(String[] args)
{
for(int line = 1; line <= 3; line++)
{
System.out.println();
for(int count = 1; count <= line; count++)
System.out.print("*");
}
}
19)option D - final, the keyword final means the value can't change
20)option D - final ,
21) option A - 0, because 50/20/6 will lead to 2/6 = 0 i.e 50/20 is 2 according to integer division, and 2/6 is 0
22)option D - Main memory
24) option c - boolean b3=false; is correct
25)option C = 32 (because the value of g is preincremented before being multiplied by 8)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.