Java Question ..............?
Q1. What is a cookie ?
Ans. A cookie is a small piece of text stored on a user's computer by the browser for a specific domain. Commonly used for authentication, storing site preferences, and server session identification.
Q2. Can we reduce the visibility of the overridden method ?

Q3. What are different types of inner classes ?

Ans. Simple Inner Class, Local Inner Class, Anonymous Inner Class , Static Nested Inner Class.

Q4. Difference between TreeMap and HashMap ?

Ans. They are different the way they are stored in memory. TreeMap stores the Keys in order whereas HashMap stores the key value pairs randomly.

Q5. What is the difference between List, Set and Map ?

Ans. List - Members are stored in sequence in memory and can be accessed through index.
Set - There is no relevance of sequence and index. Sets doesn't contain duplicates whereas multiset can have duplicates. Map - Contains Key , Value pairs.

Q6. Difference between Public, Private, Default and Protected ?



Ans. Private - Not accessible outside object scope.
Public - Accessible from anywhere.
Default - Accessible from anywhere within same package.
Protected - Accessible from object and the sub class objects.

Q7. What is servlet Chaining ?

Ans. Multiple servlets serving the request in chain.

Q8. What are the Wrapper classes available for primitive types ?

Ans. boolean - java.lang.Boolean
byte - java.lang.Byte
char - java.lang.Character
double - java.lang.Double
float - java.lang.Float
int - java.lang.Integer
long - java.lang.Long
short - java.lang.Short
void - java.lang.Void

Q9. What are concepts introduced with Java 5 ?

Ans. Generics , Enums , Autoboxing , Annotations and Static Import.

Q10. Does Constructor creates the object ?

Ans. New operator in Java creates objects. Constructor is the later step in object creation. Constructor's job is to initialize the members after the object has reserved memory for itself.

Q11. Can static method access instance variables ?

Ans. Though Static methods cannot access the instance variables directly, They can access them using instance handler.

Q12. Does Java support Multiple Inheritance ?

Ans. Interfaces does't facilitate inheritance and hence implementation of multiple interfaces doesn't make multiple inheritance. Java doesn't support multiple inheritance.

Q13. Difference between == and .equals() ?

Ans. "equals" is the member of object class which returns true if the content of objects are same whereas "==" evaluate to see if the object handlers on the left and right are pointing to the same object in memory.

Q14. Difference between Checked and Unchecked exceptions ?

Ans. Checked exceptions and the exceptions for which compiler throws an errors if they are not checked whereas unchecked exceptions and caught during run time only and hence can't be checked.

Q15. What is a Final Variable ?

Ans. Final variable is a variable constant that cannot be changed after initialization.

Q16. Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

Ans. java.lang.StringBuffer.

Q17. What is a final method ?

Ans. Its a method which cannot be overridden. Compiler throws an error if we try to override a method which has been declared final in the parent class.

Q18. Which interface does java.util.Hashtable implement?

Ans. Java.util.Map

Q19. What is an Iterator?

Ans. Iterator is an interface that provides methods to iterate over any Collection.

Q20. Which interface provides the capability to store objects using a key-value pair?

Ans. java.util.map 

Comments

Post a Comment

Popular posts from this blog

What is string immutability?