5 Replies - 1223 Views - Last Post: 27 May 2012 - 08:42 AM

#1 c9-adams  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 12-December 11

If Else Statements

Posted 10 May 2012 - 05:57 AM

I am currently studying for my Java exam and I am stuck on two questions:

1. Which answer is most accurate. An if statement :
A. contains an else clause
B. allows a choice of statements to be executed
C. may iterate multiple times
D. should end with a break statement

2. Which answer is most accurate. An else statement :
A. contains an else clause
B. should end with a break statement
C. may iterate multiple times
D. allows a choice of statements to be executed

Could anyone give me some guidance on this please.

Is This A Good Question/Topic? 0
  • +

Replies To: If Else Statements

#2 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 463
  • View blog
  • Posts: 3,166
  • Joined: 12-January 10

Re: If Else Statements

Posted 10 May 2012 - 06:08 AM

well try this

if {i eat}
I will not be hungry
else
I will be hungry
Was This Post Helpful? 0
  • +
  • -

#3 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1155
  • View blog
  • Posts: 2,533
  • Joined: 05-May 05

Re: If Else Statements

Posted 10 May 2012 - 06:21 AM

1 is obviously "allows a choice of statements," but 2 is confusing. There's no such thing as an "else statement," formally speaking. There is however an "if/else" or just plain "if" statement. For 2, having to choose between A and D, I'd say the most accurate statement is A.

This post has been edited by blackcompe: 10 May 2012 - 06:22 AM

Was This Post Helpful? 1
  • +
  • -

#4 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 463
  • View blog
  • Posts: 3,166
  • Joined: 12-January 10

Re: If Else Statements

Posted 10 May 2012 - 06:24 AM

I think 2 was written to confuse the reader either that or the person who wrote it had no clue what they were talking about...

1. B
2. A
Was This Post Helpful? 1
  • +
  • -

#5 c9-adams  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 12-December 11

Re: If Else Statements

Posted 10 May 2012 - 06:35 AM

Thanks a lot for your help.
Was This Post Helpful? 0
  • +
  • -

#6 Gungnir  Icon User is offline

  • Your Imaginary Friend

Reputation: 152
  • View blog
  • Posts: 527
  • Joined: 21-May 11

Re: If Else Statements

Posted 27 May 2012 - 08:42 AM

View Postc9-adams, on 10 May 2012 - 05:57 AM, said:

I am currently studying for my Java exam and I am stuck on two questions:

1. Which answer is most accurate. An if statement :
A. contains an else clause
B. allows a choice of statements to be executed
C. may iterate multiple times
D. should end with a break statement

2. Which answer is most accurate. An else statement :
A. contains an else clause
B. should end with a break statement
C. may iterate multiple times
D. allows a choice of statements to be executed

Could anyone give me some guidance on this please.


1 would be B, 2 would be A.

For and While loops would most resemble C. A case clause within a Switch statement should end with a break statement.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1