Core Java - Interview Questions and Answers for 'Void' - 2 question(s) found - Order By Newest Ans. void is a return type which indicates that the method returns nothing but returns the control to the line next to the method call. All methods need to have a return type and hence a method returning nothing needs to be declared void. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  void  return typeRelated Questions What are the ways to avoid LazyInitializationException ? Why do we write public static void main ? Can we use some other syntax too for main ? What is database deadlock ? How can we avoid them? Which of the following are valid declarations
1. void method(int... x){};
2. void method(int.. x){};
3. void method(int.. .x){};
4. void method(int ...x){};
5. void method(int... x){};
6. void method(int ... x){};
7. void method(int x, int... y){};
8. void method(int... x, int y){};
9. void method(int... x,int... y){};
What is the difference between these two method declarations ?
private static void method(String[] arg)
and
private static void method(String... arg) Will the static block be executed in the following code ? Why ? Which of the following is false about Constructors ? Can we overload method as following ?
void method(int... x){};
void method(int[] x){}; Can we compose the Parent Class object like this ? How should we ignore or avoid executing set of tests ? Q2. What are the different ways to avoid multi Threading related problems in Java ? Core Java
Ans. Synchronization,
Concurrent classes,
Volatile keyword,
Implementing concurrent Lock interface,
Immutable classes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  multithreading  threads  ways to avoid thread related problems  synchronization  volatile  concurrent collections Intermediate Related Questions Which keyword is used to provide explicit access of a code block to single thread ?
a. Transient
b. Final
c. Explicit
d. Synchronized Can constructors be synchronized in Java ? Explain multithreading in Java ? Why do we need Thread class even in case we execute thread using runnable interface ? What is race condition ? What is the use of runnable interface if we can always create a new thread using Thread class ? If you need to consume messages from the queue faster, which approach will you recommend - batching or concurrency ? Why threads block or enters to waiting state on I/O? Name few classes that extend Thread class ? Name few Threads related classes and interfaces ?