Question What is EJBDoclet? (EJB)
Answer EJBDoclet is an open source JavaDoc doclet that generates a lot of the EJB related source files from custom JavaDoc comments tags embedded in the EJB source file.
Question Wha is the output from System.out.println("Hello"+null); (CoreJava)
Answer Hellonull
Question Can we use the constructor, instead of init(), to initialize servlet? (Servlets)
Answer Yes , of course you can use the constructor instead of init(). There's nothing to stop you. But you shouldn't. The original reason for init() was that ancient versions of Java couldn't dynamically invoke constructors with arguments, so there was no way to give the constructur a ServletConfig. That no longer applies, but servlet containers still will only call your no-arg constructor. So you won't have access to a ServletConfig or ServletContext.
Question How can a servlet refresh automatically if some new data has entered the database? (Servlets)
Answer You can use a client-side Refresh or Server Push
Question The code in a finally clause will never fail to execute, right? (Servlets)
Answer Using System.exit(1); in try block will not allow finally code to execute.
Question Why are there no global variables in Java? (CoreJava)
Answer Global variables are considered bad form for a variety of reasons:
• Adding state variables breaks referential transparency (you no longer can understand a statement or expression on its own: you need to understand it in the context of the settings of the global variables).
• State variables lessen the cohesion of a program: you need to know more to understand how something works. A major point of Object-Oriented programming is to break up global state into more easily understood collections of local state.
• When you add one variable, you limit the use of your program to one instance. What you thought was global, someone else might think of as local: they may want to run two copies of your program at once.
For these reasons, Java decided to ban global variables.
Question What does it mean that a class or member is final? (CoreJava)
Answer A final class can no longer be subclassed. Mostly this is done for security reasons with basic classes like String and Integer. It also allows the compiler to make some optimizations, and makes thread safety a little easier to achieve.
Methods may be declared final as well. This means they may not be overridden in a subclass.
Fields can be declared final, too. However, this has a completely different meaning. A final field cannot be changed after it's initialized, and it must include an initializer statement where it's declared. For example,
public final double c = 2.998;
It's also possible to make a static field final to get the effect of C++'s const statement or some uses of C's #define, e.g.
public static final double c = 2.998;
Question What does it mean that a method or class is abstract? (CoreJava)
Answer An abstract class cannot be instantiated. Only its subclasses can be instantiated. You indicate that a class is abstract with the abstract keyword like this:
public abstract class Container extends Component {
Abstract classes may contain abstract methods. A method declared abstract is not actually implemented in the current class. It exists only to be overridden in subclasses. It has no body. For example,
public abstract float price();
Abstract methods may only be included in abstract classes. However, an abstract class is not required to have any abstract methods, though most of them do.
Each subclass of an abstract class must override the abstract methods of its superclasses or itself be declared abstract.
Question what is a transient variable? (CoreJava)
Answer transient variable is a variable that may not be serialized.
Question How are Observer and Observable used? (CoreJava)
Answer Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.
Question Can a lock be acquired on a class? (CoreJava)
Answer Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.
Question What state does a thread enter when it terminates its processing? (CoreJava)
Answer When a thread terminates its processing, it enters the dead state.
Question How does Java handle integer overflows and underflows? (CoreJava)
Answer It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment