• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

simple loop?

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again =)
Please guide me with the following question , anyone..
thank you in advance=)
Q1)
Choose right answer.
public class Example {
public static void main (String args[ ] ) {
outer :
for ( int x = 0 ; x < 2 ; x ++ ) {
inner :
for ( int a = 0 ; a < 2 ; a ++ ) {
if ( a == 1 ) {
continue outer ;
}
System.out.println ( ��a=��+a+��x=��+x )
;
}
}
}
}
��A. a=0 x=0
��B. a=0 x=1
��C. a=1 x=0
��D a=1 x=1
��E. a=2 x=0
��F. a=2 x=1
��G. a=2 x=2
ans) a,b //is this right?? First I thought this was wrong but the answer says so.. maybe this isnt that simple(?) as it looks??
I'd appreciate any comments
Q2)
How come 9.0==9.0f is true but below is false??
Double d = new Double(9.0);
Float f = f = new Float(9.0f);
d.equals(f)
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How come 9.0==9.0f is true but below is false??
Double d = new Double(9.0);
Float f = f = new Float(9.0f);
d.equals(f)
Hi, here,
9.0, 9, 9.0f all are equal(==). I guess the reason is they are all primitive types.
d.equals(f) doesn't produce true, i think the reason is that both d and f are objects, and they are different types of objects, so they couldn't be equal.
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic