General Java Questions II
stream (by default the console, too). the standard output should be used for regular
program output, the standard error for errormessages. If you start your console
program regularly both message types will appear on your screen.
But you may redirect both streams to different destinations (e.g. files), e.g. if you want
to create an error log file where you don t want to be the regualr output in.
On an UNIX you may redirect the output as follows:
java yourprog.class >output.log 2>error.log
this causes your regular output (using System.out) to be stored in output.log and your
error messages (using System.err) to be stored in error.log
Answer2: System.err is a "special" pipe that usually is directed to the standard
consolle. You can redirect the System.out with the normal pipe control (| or >), but
System.err no. If you want to put both the "normal" output and the "error" output to a
file you must use the special redirect 2>.
This allow you to send normal messages into a file or in the /null black hole, but still
receive the error messages on the console.
What is the essential difference between an abstract class and an interface?
What dictates the choice of one over the other?
Answer: You can only extend one class (abstract or not) whereas you can always
implement one or more interfaces. Interfaces are Java s way to support multiple
inheritance.
Q: There are two interfaces which have a common methods action() in them and
class implements both of them...
There are two interfaces which have a common methods action() in them and class
implements both of them, override them and then in a test class simply call action.
Which will be called?
And next: is there any way of resolving this conflict like in c++ we can
first::action();
second::action();
is something same is there in java?
Answer:
1. Neither. The compiler will refuse to compile Hello because it has two methods with
the same name and parameter list.
2. In Java, one would usually deal with this sort of situation by implementing the
interfaces in Hello s inner classes, rather than the Hello itself. You can have two inner
classes, each implementing one of the interfaces, and each with an action method
that just calls a uniquely named method in the surrounding Hello object.
Patricia
Does anyone know how could I get the size of an Enumeration object? The API
for Enumeration only contains getNext() and next().
file:///F|/a_jsite/350_tips/general_java II.htm (5 of 14) [2001 07 08 11:24:53]
footer
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved