Today's Jobs :


CORE JAVA FREQUENTLY ASKED QUESTIONS AND ANSWERS-6


CORE JAVA FREQUENTLY ASKED QUESTIONS AND ANSWERS-6


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  
 
Question: Difference between a Class and an Object ?   
Answer:   A class is a definition or prototype whereas an object is an instance or living representation of the prototype  
 
Question: What is the difference between method overriding and overloading?   
Answer:   Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments  
 
Question: What is a "stateless" protocol ?   
Answer:   Without getting into lengthy debates, it is generally accepted that protocols like HTTP are stateless i.e. there is no retention of state between a transaction which is a single request response combination  
 
Question: What is constructor chaining and how is it achieved in Java ?   
Answer:   A child object constructor always first needs to construct its parent (which in turn calls its parent constructor.). In Java it is done via an implicit call to the no-args constructor as the first statement.  
 
Question: What is passed by ref and what by value ?   
Answer:   All Java method arguments are passed by value. However, Java does manipulate objects by reference, and all object variables themselves are references  
Question: You can create a String object as String str = "abc"; Why cant a button object be created as Button bt = "abc";? Explain   
Answer:   The main reason you cannot create a button by Button bt1= "abc"; is because "abc" is a literal string (something slightly different than a String object, by-the-way) and bt1 is a Button object. The only object in Java that can be assigned a literal String is java.lang.String. Important to note that you are NOT calling a java.lang.String constuctor when you type String s = "abc";