• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

errata add+parseint???

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q1.
I have compiled & run the foll pro.(exam cram)
the output is
20
16
20
16
16
class Wrap{
public static void main(String args[]){
String s="20";
byte b1=Byte.parseByte(s);
byte b2=Byte.parseByte(s,8);
Byte b3=Byte.valueOf(s);
Byte b4=Byte.valueOf(s,8);
//byte b5=Byte.decode(s);
String s2=Byte.toString(b2);
System.out.println(b1);
System.out.println(b2);
System.out.println(b3);
System.out.println(b4);
//System.out.println(b5);
System.out.println(s2);
}
}
I could not follow how the value r derived
please explain me in detail about
parseByte() & ValueOf()
Also the foll. line gives some error.(in the above code its the comment)please help.
byte b5=Byte.decode(s);

Q 2 kindly give me the site add of errata for
a. exam cram
b.training guide(jamie jawrski)
c.exam guide by barry boone.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I don't have the book so can not confirm whether this one is a candidate for an errata.
Here is my interpretation of the results:
parseByte(s) - Assuming that the string represents byte value parseByte will return tha byte's value. So the answer will be 20.
parseByte(s, 8) - Here 8 represents the Radix (base of the numbering system). So the value 16 will be represented as 20 in the octal number system.
Byte.valueOf returns returns a new Byte object initialized to that value specified String represents a byte.
b5 won't compile because it returns Byte, not byte. Change this part of the code and you will be able to compile the program.
Hope this helps !!
Regds,
Milind
[This message has been edited by Milind (edited May 26, 2000).]
[This message has been edited by Milind (edited May 26, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

there is another discussion group for mock exam errata.
specifically, you could find the errata pages here
May be you could get more help there on this topic.
Regds.
- satya
reply
    Bookmark Topic Watch Topic
  • New Topic