Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please Help

 
Kapil Sakhuja
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PROBLEM 1
for(char c=0;c<1000;c++)
System.out.println(c);
GIVES CHARACTERS UPTIL C IS 128, AFTER THAT IT GIVES '?'
WHY ?
IF IT'S RELATED TO ENCODING SCHEME, KINDLY EXPLAIN ?
PROBLEM 2
System.err is an object of PrintStream
Also err is a static member of System Class
Please explain the above given lines.
PROBLEM 3
if i declare run() as synchronized method in a class implementing
Runnable, it is fine, it works in a synchronized manner.
But if declare run() as a synchronized method in a class
which extends Thread, it does not work in a synchronized
way. ?

 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kapil,
I can help you with the first two questions.
1. It is related to the encoding scheme. You are probably using the 8859_1 encoding scheme in which only the first 128 characters are defined (ASCII characters). If you want a different encoding scheme you need to change your default.
2. The System class defines the following class variable:
public final static PrintStream err = null;
It is of type java.io.PrintStream. It is static so we can use it without creating an instance of System:
// Print error message
System.out.println( System.err );
Regards,
Manfred
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic