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

MULTIPLE CHOICE (java programing). Choose the one alternative that best complete

ID: 3818318 • Letter: M

Question

MULTIPLE CHOICE (java programing). Choose the one alternative that best completes the statement or answers the question. 1) Which of the following statement prints smithexam1 est.txt?

1) A) System.out.println("smith"exam1" est.txt"); B) System.out.println("smithexam1 est.txt"); C) System.out.println("smith\exam1\test.txt"); D) System.out.println("smith"exam1"test.txt");

2) An int variable can hold ________. (Choose all that apply.) 2) A) 120 B) 120.0 C) "x" D) "120" E) 'x'

3) Suppose x is 1. What is x after x-= 1? 3) A) 0 B) 1 C) 2 D) -1 E) -2

4) What is y displayed in the following code?
public class Test { public static void main(String[ ] args) { int x= 1; int y= x+++ x; System.out.println("y is "+ y); } }

A) y is 1. B) y is 4. C) y is 2. D) y is 3.


5) According to Java naming convention, which of the following names can be variables? (Choose all that apply.)

A) findArea B) TOTAL_LENGTH C) FindArea D) totalLength E) class


6) What is y displayed in the following code?
public class Test1 { public static void main(String[ ] args) { int x= 1; int y= x= x + 1; System.out.println("y is "+ y); } }


A) y is 2 because x + 1 is assigned to x and then x is assigned to y. B) y is 1 because x is assigned to y first. C) y is 0. D) The program has a compile error since x is redeclared in the statement int y= x = x+ 1.

7) What is the printout of System.out.println('z'- 'a')? 7) A) z B) a C) 25 D) 26

Explanation / Answer

1) Which of the following statement prints smithexam1 est.txt?
Ans: C) System.out.println("smith\exam1\test.txt");

2) An int variable can hold ________.
e a is also correct, because a character can be implicitly cast into an int variable.
The Unicode value of character is assignment to the variable int . so in this case, the code is 120

3) Suppose x is 1. What is x after x-= 1? 3) A) 0 B) 1 C) 2 D) -1 E) -2
Ans: A) 0

4*What is y displayed in the following code?
public class Test {
public static void main(String[] args) {
int x = 1;
int y= x+++ x;   
System.out.println(“y is ” + y);
}
}
Ans :A) y is 2
5) According to Java naming convention, which of the following names can be variables? (Choose all that apply.)
ANs : A) findArea, C) FindArea


6) What is y displayed in the following code?
public class Test1 {
public static void main(String[ ] args) {
int x= 1;
int y= x= x + 1;
System.out.println("y is "+ y);
}
}

Ans : A) y is 2 because x + 1 is assigned to x and then x is assigned to y.

7) What is the printout of System.out.println('z'- 'a')?
Ans : C) 25

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