Java Questions

Q:

How to create Directory on the HD?

Answer

To create directory on the HD we use mkDir() method:


boolean mkDir();


This method returns true if the directory is created on HD


This method returns false if the directory is already existing on HD

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1813
Q:

What is the use of super call?

Answer

By using super call we can call super class constructors  from sub class constructors and we can initialize super class private data.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1807
Q:

What is the SimpleTimeZone class?

Answer

SimpleTimeZone is a concrete subclass of TimeZone class. The TimeZone class represents a time zone, that is to be used with Gregorian calendar.


The SimpleTimeZone is created by using the base time zone offset from GMT time zone ID and rules, for starting and ending the time of daylight.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1805
Q:

How to do MultiThreading in Java?

Answer

To do multi threading in java we use interfaces and classes defined in java.lang package.


Those classes and interfaces are:


Java.lang.Runnable, Java.lang. Thread, Java.lang.ThreadGroup

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1800
Q:

How do you traverse through a collection using its Iterator?

Answer

To use an iterator to traverse through the contents of a collection, follow these steps:


- Obtain an iterator to the start of the collection by calling the collections iterator() method.


- Set up a loop that makes a call to hasNext(). Have the loop iterate as long as hasNext() returns true.


- Within the loop, obtain each element by calling next().

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1794
Q:

What are Native methods in Java?

Answer

Java applications can call code written in C, C++, or assembler. This is sometimes done for performance and sometimes to access the underlying host operating system or GUI API using the JNI.


 


The steps for doing that are:


First write the Java code and compile it


Then create a C header file


Create C stubs file


Write the C code


Create shared code library (or DLL)


Run application

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1794
Q:

What is the Set interface ?

Answer

- The Set interface provides methods for accessing the elements of a finite mathematical set


- Sets do not allow duplicate elements


- Contains no methods other than those inherited from Collection


- It adds the restriction that duplicate elements are prohibited


- Two Set objects are equal if they contain the same elements

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1775
Q:

What is local class?

Answer

Local class is class defined inside method


EX;


class A { // top level class


  public static void main(string[] args) {


   class B { // local class


   }


}


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1773