More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. Class loaders are hierarchical. The very first class is specially loaded with the help of static main() method declared in your class. All the subsequently loaded classes are loaded by the classes, which are already loaded and running.
Help us improve. Please let us know the company, where you were asked this question :
Java does not support destructors but rather adds a finalize() method. Finalize methods are invoked by the garbage collector prior to reclaiming the memory occupied by the object, which has the finalize() method.
Java does not include structures or unions because the traditional data structures are implemented as an object oriented framework.
C++ compiles to machine language , when Java compiles to byte code .
In C++ the programmer needs to worry about freeing the allocated memory , where in Java the Garbage Collector takes care of the the unneeded / unused variables.
Java is platform independent language but c++ is depends upon operating system.
Java uses compiler and interpreter both and in c++ their is only compiler.
C++ supports operator overloading whereas Java doesn't.
Internet support is built-in Java but not in C++. However c++ has support for socket programming which can be used.
Java does not support header file, include library files just like C++ .Java use import to include different Classes and methods.
There is no goto statement in Java.
There is no scope resolution operator :: in Java. It has . using which we can qualify classes with the namespace they came from.
Java is pass by value whereas C++ is both pass by value and pass by reference.
Java Enums are objects instead of int values in C++
C++ programs runs as native executable machine code for the target and hence more near to hardware whereas Java program runs in a virtual machine.
C++ was designed mainly for systems programming, extending the C programming language whereas Java was created initially to support network computing.
C++ allows low-level addressing of data. You can manipulate machine addresses to look at anything you want. Java access is controlled.
C++ has several addressing operators . * & -> where Java has only one: the .
We can create our own package in Java(set of classes) but not in c and c++.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  java   c++   difference between java and c++   programming concepts   programming languages   architecture   technical architect   technical lead Asked in 1 Companies
Q1984. Difference between static vs. dynamic class loading?
Ans. static loading - Classes are statically loaded with Java new operator.
dynamic class loading - Dynamic loading is a technique for programmatically invoking the functions of a class loader at run time.
Class.forName (Test className);
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  java   jvm   memory management   class loaders  classloaders   static class loading   static loading   dynamic class loading   dynamic loading Asked in 2 Companiesexpert  frequent
Q1985. Tell something about BufferedWriter ? What are flush() and close() used for ?
Ans. BufferedWriter is temporary source for data storage.BufferedWriter is used to write character data to the file.Flush() is method available in B.W which ensures that all data items are written to file including last character.Close() is used to closes the character output stream.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Scanner class introduced in Java 1.5 for reading Data Stream from the imput device. Previously we used to write code to read a input using DataInputStream. After reading the stream , we can convert into respective data type using in.next() as String ,in.nextInt() as integer, in.nextDouble() as Double etc
Help us improve. Please let us know the company, where you were asked this question :
Ans. final - constant variable, objects cannot be de-referenced, restricting method overriding, restricting class sub classing.
finally - handles exception. The finally block is optional and provides a mechanism to clean up regardless of what happens within the try block. Use the finally block to close files or to release other system resources like database connections, statements etc.
finalize() - method helps in garbage collection. A method that is invoked before an object is discarded by the garbage collector, allowing it to clean up its state.
Which of the following is wrong for final instance variables ?
They cannot be changed after initialization
They can be initialized directly within static method
They can be declared and initialized together at the same place
They can be initialized within constructor
Which of the following is false for final ?
Final methods cannot be overriden
Final methods cannot be overloaded
Final classes cannot be subclassed
Final class cannot be abstract
Which of the following methods are used by Java Garbage Collection Mechanism ?
final
finally
finalize
All of the above
In which case finally won't get executed ?
in case of exception
in case of normal execution
in case of return statement before end of try block
in case of force program termination
Q1991. When do you get ClassCastException?
or
What is ClassCastException ?
Ans. As we only downcast class in the hierarchy, The ClassCastException is thrown to indicate that code has attempted to cast an object to a subclass of which it is not an instance.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Garbage Collector wont remove a strong reference.
A soft reference will only get removed if memory is low.
A weak reference will get removed on the next garbage collection cycle.
A phantom reference will be finalized but the memory will not be reclaimed. Can be useful when you want to be notified that an object is about to be collected.
Help us improve. Please let us know the company, where you were asked this question :
Ans. When a task invokes yield(), it changes from running state to runnable state. When a task invokes sleep(), it changes from running state to waiting/sleeping state.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  java   threads   multi threading   scheduling   thread states   yield   sleeping
Usually asked only to fresh graduates and less experienced developers.
Q1995. What is a daemon thread? Give an Example ?
Ans. These are threads that normally run at a low priority and provide a basic service to a program or programs when activity on a machine is reduced. garbage collector thread is daemon thread.
Help us improve. Please let us know the company, where you were asked this question :
What kind of thread is Garbage collection thread ?
Daemon Thread
User Thread
System Thread
Active Thread
Which of following is Daemon Thread ?
Thread Scheduler
Daemon Thread
Both of above
None of above
Q1996. What is the difference between AWT and Swing?
Ans. Swing provides both additional components like JTable, JTree etc and added functionality to AWT-replacement components.
Swing components can change their appearance based on the current “look and feel†library that’s being used.
Swing components follow the MVC paradigm, and thus can provide a much more flexible UI.
Swing provides extras for components, such as icons on many components, decorative borders for components, tool tips for components etc.
Swing components are lightweight than AWT.
Swing provides built-in double buffering ,which means an off-screen buffer is used during drawing and then the resulting bits are copied onto the screen.
Swing provides paint debugging support for when you build your own component.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  java   awt   java ui   swing   difference between swing and awt   architecture
Q1997. What is the order of method invocation in an applet?
Ans. public void init() public void start() public void stop() public void destroy()
Help us improve. Please let us know the company, where you were asked this question :
Ans. instance variables and objects are stored on heap and the references are stored on stack whereas static variables are stored in the method area of heap.
Help us improve. Please let us know the company, where you were asked this question :
public static void main (String args[]) {
String localVariable = "local Variable";
}
}
Where will the value 'static Variable' be stored ?
Stack Memory Segment
Heap Memory Segment
Runtime Constant Pool within Heap Segment
Code Segment
Q2000. What are the components of J2EE ?
Ans. applets Client component like Client side Java codes. Web component like JSP, Servlet WAR Enterprise JavaBeans like Session beans, Entity beans, Message driven beans Enterprise application like WAR, JAR, EAR
Help us improve. Please let us know the company, where you were asked this question :
Ans. A DOM (Document Object Model) parser creates a tree structure in memory from an input document whereas A SAX (Simple API for XML) parser does not create any internal structure.
A SAX parser serves the client application always only with pieces of the document at any given time whereas A DOM parser always serves the client application with the entire document no matter how much is actually needed by the client.
A SAX parser, however, is much more space efficient in case of a big input document whereas DOM parser is rich in functionality.
Use a DOM Parser if you need to refer to different document areas before giving back the information. Use SAX is you just need unrelated nuclear information from different areas.
Xerces, Crimson are SAX Parsers whereas XercesDOM, SunDOM, OracleDOM are DOM parsers.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  java   xml   parsers   sax   dom parser   difference   architecture   technical lead   technical architect  markup language   sax vs dom Asked in 14 Companies  frequent
Ans. DTD or Document Type Definition is a standard agreed upon way of communication between two parties. Your application can use a standard DTD to verify that data that you receive from the outside world is valid and can be parsed by your parser.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  xml   markup language   dtd   document type definition   architecture
Ans. Stands for Java API for XML Processing. This provides a common interface for creating and using SAX, DOM, and XSLT APIs in Java regardless of which vendor’s implementation is actually being used.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  java   java api   xml   xml processing   jaxp   abbreviation   technologies
Ans. Stands for Java API for XML Binding. This standard defines a mechanism for writing out Java objects as XML and for creating Java objects from XML structures.
Help us improve. Please let us know the company, where you were asked this question :
Ans. LDAP servers are typically used in J2EE applications to authenticate and authorise users. LDAP servers are hierarchical and are optimized for read access, so likely to be faster than database in providing read access.
Help us improve. Please let us know the company, where you were asked this question :
LikeDiscussCorrect / Improve  java   j2ee   ldap   servers   authentication   authorization   architecture   technical lead   technical architect  production support Asked in 1 Companies