Java Questions

Q:

An algorithm written once which can be used in many places is called

A) Block B) Function
C) Datatype D) None
 
Answer & Explanation Answer: B) Function

Explanation:

Function is an algorithm which can be used any where in the program when required

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2475
Q:

Why static method can not call non static method of the same class?

Answer

bcoz the static method does not contains the 'this' reference.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2473
Q:

When finally block is executed?

Answer

If exception is generated  in try and if that exception is not catch by any catch then finally is executed.


If exception is generated in try and if that exception is caught by one of catch statements then also finally is executed.


if no exception is generated then also finally is executed.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2469
Q:

Which key word is to be used to tell the JVM to skip the variable while performing the serialization process of the object containing it?

A) Transcient B) Volatile
C) Static D) Final
 
Answer & Explanation Answer: A) Transcient

Explanation:

If you mark an instance variable as transient, you're telling the JVM to skip (ignore) this variable when you attempt to serialize the object containing it.

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2398
Q:

What is Thread?

Answer

A Thread is a block of code that can be executed in parallel with another block of code.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2359
Q:

What is the purpose of declaring a variable as final?

Answer A final variable's value can't be changed. final variables should be initialized before using them.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2346
Q:

How can you avoid callback hells ?

Answer

There are lots of ways to solve the issue of callback hells:


1. Modularization: break callbacks into independent functions
2. Use a control flow library, like async
3. Use generators with Promises
4. Use async/await (note that it is only available in the latest v7 release and not in the LTS version)

Report Error

View answer Workspace Report Error Discuss

Subject: Java
Job Role: Analyst , IT Trainer

3 2344
Q:

What is Overloading Polymorphism?

Answer

Overloading allows multiple functions to exist with same name but different parameters. Again if you take bike as an example, it has a function “Start” with two forms i.e. ’Auto Start’ and ’kick start’.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2342