Java Questions

Q:

What is Auto boxing and unboxing?

Answer

Autoboxing is the process of converting a primitive type data into its corresponding wrapper class object instance.


Example:


Integer number = new Integer (100); // number is now refers to the object 100


 


Unboxing is the process of converting a wrapper instance into a primitive type.


Example: 


Integer number = new Integer (100); 


int num = number;// without type casting number would be changed into int type

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1422
Q:

Explain Overriding Polymorphism.?

Answer

Overriding means changing behavior of methods of base class in derive class by overriding the base class methods. If class A is a base class with method ’calculate’ and class B inherits class A, thus derives method ’calculate’ of class A. The behavior of ’calculate’ in class B can be changed by overriding it.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1420
Q:

What is JDBC Driver ?

Answer

The JDBC Driver provides vendor-specific implementations of the abstract classes provided by the JDBC API. This driver is used to connect to the database.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1420
Q:

What is the Dictionary class?

Answer

- The Dictionary class is an abstract class.


- Classes like Hashtable which map keys to values inherit from this class. 


- An object can be looked for if a dictionary and a key is provided.


- Any non-null object can be used as a key and as a value.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 1413
Q:

How to get last modified date of a file?

Answer

long lastModified();


we can give this return value to a date object and we can get data to be displayed.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1408
Q:

How does a try statement determine which catch clause should be used to handle an exception?

Answer

When an exception is thrown , the catch block of the try statement are examined in the order in which they appear. The first catch block that is capable of handling the exception is executed. The remaining catch blocks are ignored

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1407
Q:

What do you understand by private, protected and public?

Answer

These are accessibility modifiers. Private is the most restrictive, while public is the least restrictive. There is no real difference between protected and the default type (also known as package protected) within the context of the same package, however the protected keyword allows visibility to a derived class in a different package.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1406
Q:

What are the the different ways for creating a thread?

Answer

A thread can be created by subclassing Thread, or by implementing the Runnable interface.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1400