Thursday, June 24, 2010

CORE JAVA CONTD...1

QUESTION: How is rounding performed under integer division?
ANSWER: The fractional part of the result is truncated. This is known as rounding toward zero.

QUESTION: What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
ANSWER: The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

QUESTION: What classes of exceptions may be caught by a catch clause?
ANSWER: A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.
QUESTION: If a class is declared without any access modifiers, where may the class be accessed?
ANSWER: A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.

QUESTION: Does a class inherit the constructors of its superclass?
ANSWER: A class does not inherit constructors from any of its superclasses.

QUESTION: What is the purpose of the System class?
ANSWER: The purpose of the System class is to provide access to system resources.

QUESTION: Name the eight primitive Java types.
ANSWER: The eight primitive types are byte, char, short, int, long, float, double, and boolean.

QUESTION: Which class should you use to obtain design information about an object?
ANSWER: The Class class is used to obtain information about an object's design.

QUESTION: can the Kawa or any another J-editor export a .EXE file and to be has an install shield
ANSWER: I didn't know i need an ANSWER.
QUESTION: What modifiers are allowed for methods in an Interface?
ANSWER: Only public and abstract modifiers are allowed for methods in interfaces.
QUESTION: What are the different identifier states of a Thread?
ANSWER: The different identifiers of a Thread are:
R - Running or runnable thread
S - Suspended thread
CW - Thread waiting on a condition variable
MW - Thread waiting on a monitor lock
MS - Thread suspended waiting on a monitor lock

QUESTION: What is Externalizable?
ANSWER: Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in)

QUESTION: I made my class Cloneable but I still get 'Can't access protected method clone. Why?
ANSWER: Yeah, some of the Java books, in particular "The Java Programming Language", imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but that's not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesn't do anything special and just calls super.clone().

QUESTION: What is a local, member and a class variable?
ANSWER: Variables declared within a method are "local" variables. Variables declared within the class i.e not within any methods are "member" variables (global variables). Variables declared within the class i.e not within any methods and are defined as "static" are class variables

QUESTION: What gives java it's "write once and run anywhere" nature?
ANSWER: Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platorm specific and hence can be fed to any platform. After being fed to the JVM, which is specific to a particular operating system, the code platform specific machine code is generated thus making java platform independent.

QUESTION: What are the four corner stones of OOP ?
ANSWER: Abstraction, Encapsulation, Polymorphism and Inheritance