Difference between System class and Runtime class?

System Class

  • It is a final class available in java.lang package.
  • We can't instantiated this class because the default constructor is private.
  • All the members of this class is static.    
  • Three constants defined named in ,out and err.  
  • in is a reference variable of InputStream and directed to standard input device called keyboard.
  • out and err are reference variables of type PrintStream and pointing towards standard output device called Monitor.
Runtime Class
  • It is a final class available in java.lang package.
  • We can't instantiated this class because the default constructor is private.
  • It follows Singleton Design pattern.
  • It contains non-static methods.
Way of accessing Runtime object is
Runtime rt = Runtime.getRuntime()

0 comments :

Post a Comment