Java Questions

Q:

What is the difference between processes and threads ?

Answer

- A process is an execution of a program, while a Thread is a single execution sequence within a process.


- A process can contain multiple threads. A Thread is sometimes called a lightweight process.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2602
Q:

Is it possible to nest functions in javascript?

Answer

Yes, it is possible to nest functions in javascript.

Report Error

View answer Workspace Report Error Discuss

Subject: Java
Job Role: IT Trainer

11 2600
Q:

What is Interpreter in Java?

Answer

  • An Interpreter is a program that reads in as input a source program, along with data for the program, and translates the source program step by step.


 


The Java interpreter decodes each lines bytecode and runs a series of machine instructions for that bytecode. The JVM takes the byte code and generates machine code. The byte code is compiled to machine code, and the machine code is executed.

Report Error

View answer Workspace Report Error Discuss

7 2585
Q:

What is the difference between ViewState and SessionState?

Answer

'ViewState' is specific to a page in a session.
'SessionState' is specific to user specific data that can be accessed across all pages in the web application.

Report Error

View answer Workspace Report Error Discuss

Subject: Java
Job Role: Analyst , IT Trainer

3 2562
Q:

What are the restrictions when overriding a method ?

Answer

Overridden methods must have the same name, argument list, and return type (i.e., they must have the exact signature of the method we are going to override, including return type.)


The overriding method cannot be less visible than the method it overrides( i.e., a public method cannot be override to private).


The overriding method may not throw any exceptions that may not be thrown by the overridden method

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2544
Q:

What is the common usage of serialization? What exceptions occur during serialization?

Answer

The object need to be serialized when it’s sent over a network and when it’s state is saved. Exceptions which occur during serialization are:


a. transient fields


b. when the base class is serialized then only base class fields are handled.


c. static fields are ignored because they are not part of any state.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 2534
Q:

How does thread synchronization occurs inside a monitor?

Answer

A Monitor defines a lock and condition variables for managing concurrent access to shared data. The monitor uses the lock to ensure that only a single thread inactive in the monitor code at any time.


A monitor allows only one thread to lock an object at once.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2524
Q:

Which king class properly represents the relationship "King has a best friend who is a Soldier"?

A) class King extends Soldier { } B) class King implements Soldier { }
C) class King { private BestFriend Soldier; } D) class King { private Soldier bestFriend; }
 
Answer & Explanation Answer: D) class King { private Soldier bestFriend; }

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2508