Académique Documents
Professionnel Documents
Culture Documents
INTRODUCTION TO JAVA
hashCode()
Or
All Java programs are compiled into class files that contain
byte codes. These byte codes can be run in any platform and
hence java is said to be platform independent.
void: main does not return anything so the return type must
be void
Or
Or
Or
Or
Or
Or
Or
Or
What does it mean that a class or member is final?
Example
int i = 1000;
Example
long i = 700.20;
Or
Or
Object.
The 8 primitive types are byte, char, short, int, long, float,
double, and boolean.
Or
What are class variables?
Or
Or
It uses those low order bytes of the result that can fit into
the size of the type allowed by the operation.
How can one prove that the array is not null but
empty?
Add two variables and assign the value into First variable.
Subtract the Second value with the result Value. and assign
to Second variable. Subtract the Result of First Variable With
Result of Second Variable and Assign to First Variable.
Example:
synchronized(XYZ.class) {
Example:
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
Output:
Hello
World
2. JAVA PACKAGES
Or
Or
Two methods may not have the same name and argument
list but different return types.
Or
What are the Object and Class classes used for? Which
class should you use to obtain design information
about an object? Differentiate between a Class and an
Object?
Or
Or
{
static int cntr=0;
test1()
{ cntr++;
if(cntr>2)
System.out.println("hello 1");
System.out.println("hello 2");
1.new operator
3.newInstance
4.object.clone
Or
Or
Or
Or
It is a daemon thread.
5.OBJECT SERIALISATION
Or
What is serialization?
One should make sure that all the included objects are also
serializable. If any of the objects is not serializable then it
throws a NotSerializableException.
Or
Or
What is Externalizable?
6.JAVA COLLECTIONS
Or
Map m = Collections.synchronizeMap(hashMap);
a. Vector
b. ArrayList
c. LinkedList
d. None of the above
Similarities:
Neither Abstract classes nor Interface can be instantiated.
Or
Example
public abstract class AbstractExample {
public AbstractExample(){
System.out.println("In AbstractExample()");
}
}
8.JAVA EXCEPTIONS
Or
try{
//some statements
}
catch{
//statements when exception is caught
}
finally{
//statements executed whether exception occurs or
not
}
9.JAVA SWINGS
Or
validate()
Or
Or
What is deadlock?
When two threads are waiting for each other and can’t
proceed until the first thread obtains a lock on the other
thread or vice versa, the program is said to be in a deadlock.
Or
Or
Or
What is synchronization?