09.02.2017 Views

Question 1 Which of the following is the correct syntax for an if statement? A. if (x < 10) { size = "Small"; } else { size = "Medium"; }

Question 1 Which of the following is the correct syntax for an if statement? A. if (x < 10) { size = "Small"; } else { size = "Medium"; }

Question 1 Which of the following is the correct syntax for an if statement? A. if (x < 10) { size = "Small"; } else { size = "Medium"; }

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Buy here:<br />

http://student.l<strong>an</strong>d/question-1-which-<strong>of</strong>-<strong>the</strong>-<strong>following</strong>-<strong>is</strong>-t<br />

he-<strong>correct</strong>-<strong>syntax</strong>-<strong>for</strong>-<strong>an</strong>-<strong>if</strong>-<strong>statement</strong>-a-<strong>if</strong>-x-<strong>10</strong>-<strong>size</strong>-small<br />

-<strong>else</strong>-<strong>size</strong>-medium/<br />

<strong>Question</strong> 1<br />

<strong>Which</strong> <strong>of</strong> <strong>the</strong> <strong>following</strong> <strong>is</strong> <strong>the</strong> <strong>correct</strong> <strong>syntax</strong> <strong>for</strong> <strong>an</strong> <strong>if</strong> <strong>statement</strong>?<br />

A<br />

<strong>if</strong> (x < <strong>10</strong>) { <strong>size</strong> = "Small"; }<br />

.<br />

<strong>else</strong> { <strong>size</strong> = "Medium"; }<br />

B<br />

<strong>if</strong> (x < <strong>10</strong>); { <strong>size</strong> = "Small"; }<br />

.<br />

<strong>else</strong> (x < 20) { <strong>size</strong> =<br />

"Medium"; }<br />

C<br />

<strong>if</strong> { <strong>size</strong> = "Small"; }<br />

.


<strong>else</strong> (x < 20) { <strong>size</strong> =<br />

"Medium"; }<br />

D<br />

<strong>if</strong> (x < <strong>10</strong>) { <strong>size</strong> = "Small"; }<br />

.<br />

<strong>else</strong> (x < 20) { <strong>size</strong> =<br />

"Medium"; }<br />

0.25 points<br />

<strong>Question</strong> 2<br />

What <strong>is</strong> <strong>an</strong> object?<br />

A<br />

.<br />

An entity in your program that <strong>is</strong> m<strong>an</strong>ipulated by calling<br />

methods.<br />

B<br />

Any value stored in a variable.<br />

.


C<br />

A sequence <strong>of</strong> instructions.<br />

.<br />

D<br />

Any input to a method.<br />

.<br />

0.25 points<br />

<strong>Question</strong> 3<br />

<strong>Which</strong> <strong>of</strong> <strong>the</strong> <strong>following</strong> <strong>statement</strong>s about methods <strong>is</strong> <strong>correct</strong>?<br />

A<br />

Methods are stored in variables.<br />

.<br />

B<br />

.<br />

A method <strong>is</strong> a sequence <strong>of</strong> instructions that could access <strong>the</strong> data<br />

<strong>of</strong> <strong>an</strong> object.<br />

C<br />

A method c<strong>an</strong> be called on <strong>an</strong>y object in <strong>an</strong>y class.<br />

.


D<br />

A method name <strong>is</strong> unique across <strong>the</strong> entire program.<br />

.<br />

0.25 points<br />

<strong>Question</strong> 4<br />

0.25 points<br />

<strong>Question</strong> 5<br />

<strong>Which</strong> <strong>of</strong> <strong>the</strong> <strong>following</strong> <strong>statement</strong>s with comments <strong>is</strong>(are) valid?<br />

I. int cnt = 0; /* Set count to 0<br />

II. int cnt = 0; /* Set count to 0 */<br />

III. int cnt = 0; // Set count to 0<br />

A<br />

Only I <strong>is</strong> valid<br />

.


B<br />

Only III <strong>is</strong> valid<br />

.<br />

C<br />

I <strong>an</strong>d II are valid<br />

.<br />

D<br />

.<br />

II <strong>an</strong>d III are<br />

valid<br />

0.25 points<br />

<strong>Question</strong> 6<br />

What will be <strong>the</strong> value stored in <strong>the</strong> variable x after <strong>the</strong> execution <strong>of</strong> <strong>the</strong><br />

<strong>following</strong> code snippet?<br />

int a = <strong>10</strong>;<br />

int b = 20;<br />

int c = 2;


int x = b / a /*c*/;<br />

A<br />

4<br />

.<br />

B<br />

2<br />

.<br />

C<br />

1<br />

.<br />

D<br />

.<br />

The code has a <strong>syntax</strong><br />

error

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!