Java Questions

Q:

How to check that whether the file object is pointing a folder or not?

Answer

boolean isDirectory();

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1676
Q:

What is Shallow and deep cloning in Java?

Answer

Cloning refers to creating duplicate copies of objects in java.


Shallow Cloning: Shallow cloning is a bitwise copy of an object. New object is created which is an exact copy that of the original one. In case any objects are referring the fields of these objects, just the references are copied.


Deep Cloning: In deep cloning, complete duplicate copy of the original copy is created. Deep cloning creates not only the primitive values of the original objects but also copies all its sub objects as well.


Clonable interface is used to perform cloning in java.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1670
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 1668
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 1663
Q:

What are the steps required to execute a query in JDBC?

Answer

First we need to create an instance of a JDBC driver or load JDBC drivers, then we need to register this driver with DriverManager class. Then we can open a connection. By using this connection , we can create a statement object and this object will help us to execute the query.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1646
Q:

What are wrapped classes ?

Answer

Wrapped classes are classes that allow primitive types to be accessed as objects.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1645
Q:

What are the various elements of OOPS?

Answer

Various elements of OOP are:


• Object


• Class


• Method


• Encapsulation


• Information Hiding


• Inheritance


• Polymorphism

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1643
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 1627