Consultancy Services jobs Etisalat CEO ZANTEL
etisalat

Custom Search
Share/Save/Bookmark Subscribe

Core Basics of Java FAQ

Posted by Anonymous | 4:55 PM | | 0 comments »

Core Java basics


Etisalat

DEVELOPER

bangalore

india

BLOGGER

SEX





Can I have multiple main methods in the same class? »
No the program fails to compile. The compiler says that the main method is already defined in the class.

Can an application have multiple classes having main method? »
Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method.

How can one prove that the array is not null but empty? »
Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.

What if I do not provide the String array as the argument to the method? »Program compiles but throws a runtime error “NoSuchMethodError”.

What if I write static public void instead of public static void? »
Program compiles and runs properly.

What if the static modifier is removed from the signature of the main method? »
Program compiles. But at runtime throws an error “NoSuchMethodError”.

What if the main method is declared as private? »
The program compiles properly but at runtime it will give “Main method not public.” message.A compilation unit is a Java source code file.

What is the purpose of garbage collection? »
The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources may be reclaimed and reused.

How are this and super used? »
this is used to refer to the current object instance. super is used to refer to the variables and methods of the superclass of the current object instance.

What interface must an object implement before it can be written to a stream as an object? »
An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.

What is your platform’s default character encoding? »
If you are running Java on English Windows platforms, it is probably Cp1252. If you are running Java on English Solaris platforms, it is most likely 8859_1.

What happens when you add a double value to a String? »
The result is a String object.162.

What is the difference between the File and RandomAccessFile classes? »
The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.

What classes of exceptions may be thrown by a throw statement? »
A throw statement may throw any expression that may be assigned to the Throwable type.The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.

If an object is garbage collected, can it become reachable again? »
Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.

What are the legal operands of the instanceof operator? »
The left operand is an object reference or null value and the right operand is a class, interface, or array type.

Why are the methods of the Math class static? »
So they can be invoked as if they are a mathematical code library.

How is it possible for two String objects with identical values not to be equal under the == operator? »
The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory.

What is the relationship between a method’s throws clause and the exceptions that can be thrown during the method’s execution? »
A method’s throws clause must declare any checked exceptions that are not caught within the body of the method.Under what conditions is an object’s finalize() method invoked by the garbage collector? »The garbage collector invokes an object’s finalize() method when it detects that the object has become unreachable.

What is the difference between a field variable and a local variable? »
A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.

What class allows you to read objects directly from a stream? »
The ObjectInputStream class supports the reading of objects from input streams.

What class of exceptions are generated by the Java run-time system? »The Java runtime system generates RuntimeException and Error exceptions.

What happens when you invoke a thread’s interrupt method while it is sleeping or waiting? »
When a task’s interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.

Which non-Unicode letter characters may be used as the first character of an identifier? »
The non-Unicode letter characters $ and _ may appear as the first character of an identifier

If a method is declared as protected, where may the method be accessed? »
A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

Which class is the immediate superclass of the Container class? »
ComponentCan an exception be rethrown? »Yes, an exception can be rethrown.

What is the difference between static and non-static variables? »
A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.

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

What happens when a thread cannot acquire a lock on an object? »
If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object’s lock, it enters the waiting state until the lock becomes available.

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

Can an object be garbage collected while it is still reachable? »
A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected.

What is an object’s lock and which objects have locks? »
An object’s lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object’s lock. All objects and classes have locks. A class’s lock is acquired on the class’s Class object.

If a variable is declared as private, where may the variable be accessed? »
A private variable may only be accessed within the class in which it is declared.

Can a Byte object be cast to a double value? »No, an object cannot be cast to a primitive value.What value does read() return when it has reached the end of a file? »The read() method returns -1 when it has reached the end of a file.The high-level thread states are ready, running, waiting, and dead.

What method is invoked to cause an object to begin executing as a separate thread? »
The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.The = operator is right associative.

What invokes a thread’s run() method? »
After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread’s run() method when the thread is initially executed.

When a thread is created and started, what is its initial state? »
A thread is in the ready state after it has been created and started.

To what value is a variable of the String type automatically initialized? »
The default value of a String type is null.

When a thread blocks on I/O, what state does it enter? »
A thread enters the waiting state when it blocks on I/O.

What value does readLine() return when it has reached the end of a file? »
The readLine() method returns null when it has reached the end of a file.

What is the difference between preemptive scheduling and time slicing? »
Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on […]

What is synchronization and why is it important? »
With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object’s value. This often leads to significant errors.

How are Observer and Observable used? »
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.

0 comments

free counters
Your Ad Here

Cross Rates Powered by Forex Pros - The Forex Trading Portal.
java.sun.com jobs etisalat actress hot sex
Bangalore, 04 March 2008, UAE Telecoms Gaint founds ‘technologia’ in Bangalore to create continuous stream of new innovations. Affordable Website Design
Free Search Engine Submission
Free Search Engine Submission
Submit Your Site To The Web's Top 50 Search Engines for Free! BigDirectory.org - free url submission, online website directory National Directory Free Web Directory Submission - Dotster Directory Link Popularity Building
We offers advanced Link Popularity Services for small to large static, dynamic and eCommerce websites.
http://www.links-builder.com
India Search Engine and Web Directory Superblog Directory
HOT SEX,NUDE TECHNOLOGIAWORLD SQL JAVA SUN BEA IBM HCL SATYAM TCS CHIRANJEEVI CHIRU PAWAN HANSIKA SANGAVI SNEHA TAMIL SEX MALLU MASALA