• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 81 : - Parsers? DOM vs SAX parser ?

Answer - 81 : - Parsers are fundamental xml components, a bridge between XML documents and applications that process that XML. The parser is responsible for handling xml syntax, checking the contents of the document against constraints established in a DTD or Schema. DOM 1. Tree of nodes 2. Memory: Occupies more memory, preffered for small XML documents 3. Slower at runtime 4. Stored as objects 5. Programmatically easy 6. Ease of navigation SAX 1. Sequence of events 2. Doesn't use any memory preferred for large documents 3. Faster at runtime 4. Objects are to be created 5. Need to write code for creating objects 6. Backward navigation is not possible as it sequentially processes the document

Question - 82 : - Why Java does not support multiple inheritance ?

Answer - 82 : - This is a classic question. Yes or No depends on how you look at Java. If you focus on the syntax of "extends" and compare with C++, you may answer 'No' and give explanation to support you. Or you may answer 'Yes'. Recommend you to say 'Yes'. Java DOES support multiple inheritance via interface implementation. Some people may not think in this way. Give explanation to support your point.

Question - 83 : - How to define an Abstract class?

Answer - 83 : - A class containing abstract method is called Abstract class. An Abstract class can't be instantiated. Example of Abstract class: abstract class testAbstractClass { protected String myString; public String getMyString() { return myString; } public abstract string anyAbstractFunction(); }

Question - 84 : - Which characters may be used as the second character of an identifier, but not as the first character of an identifier?

Answer - 84 : - The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.

Question - 85 : - What are the high-level thread states?

Answer - 85 : - The high-level thread states are ready, running, waiting, and dead.

Question - 86 : - Explain the usage of Java packages.

Answer - 86 : - This is a way to organize files when a project consists of multiple modules. It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.

Question - 87 : - What is NullPointerException and how to handle it?

Answer - 87 : - When an object is not initialized, the default value is null. When the following things happen, the NullPointerException is thrown: --Calling the instance method of a null object. --Accessing or modifying the field of a null object. --Taking the length of a null as if it were an array. --Accessing or modifying the slots of null as if it were an array. --Throwing null as if it were a Throwable value. The NullPointerException is a runtime exception. The best practice is to catch such exception even if it is not required by language design.

Question - 88 : - How can you force garbage collection?

Answer - 88 : - You can't force GC, but could request it by calling System.gc(). JVM does not guarantee that GC will be started immediately.

Question - 89 : - Which java.util classes and interfaces support event handling?

Answer - 89 : - The EventObject class and the EventListener interface support event processing.

Question - 90 : - What is casting?

Answer - 90 : - There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners