{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

practicemult

# practicemult - Practice multiple choice exam questions...

This preview shows pages 1–3. Sign up to view the full content.

Practice multiple choice exam questions. Question 1 (2 marks) Which of the following is an INVALID identifier? A Char B char C _char D _char_ E char\$ Question 2 (2 marks) What is the syntax problem with the following expression (a + 2b) / c / g A nothing B brackets needed around c C 2b should be 2 * b D You cannot have 2 divide operators in an expression E brackets needed around c / g Question 3 (2 marks) int sum = 0; for (int k = 1; k <= 5; k++) { int n = k; // STATEMENT GOES HERE } The above code fragment is intended to add the integers from 1 to 5 inclusive. Which of the following statements (replacing the comment in the code fragment) does NOT do this correctly? A sum = sum + n; B sum += n; C sum += n++; D sum += ++n; E sum += n--; Question 4 (2 marks) System.out.println (13 / 5 * 6 % 7); What is the output A 0 B 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
C 2 D 3 E none of the above Question 5 (2 marks) int sum = 0; int k = 7146; do { sum = sum + k % 10; k = k / 10; } while (k > 0); System.out.println (sum); What is the output. Select the answer that is closest A 5 B 10 C 15 D 20 E 25 Question 6 (2 marks) public class Q6 { public static void main (String[] args) { int i, j, k, sum; i=5; j=35; k=75; sum = j + 4 % i * k - 6; System.out.println ("result : " + sum.Valueof () ); } } What is the output? A 329 B 294 C 104 D 33 E Compile-time error Question 7 (2 marks) An instance variable is best defined as A a variable contained in each object of a class B a static variable C a variable local to a method D a constant variable E a parameter variable Question 8 (2 marks)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern