ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Latest Java Interview Questions And Answers for fresher and experience |

Автор: Coding World

Загружено: 2023-01-19

Просмотров: 348

Описание: 1.Can we make array volatile in Java?

Yes, you can make an array volatile in Java but only the reference which is pointing to an array, not the whole array.
What I mean, if one thread changes the reference variable to points to another array, that will provide a volatile guarantee, but if multiple threads are changing individual array elements they won't be having happens before guarantee provided by the volatile modifier.

2.How do you call #wait() method? using if block or loop? Why?

wait() method should always be called in loop because it's possible that until thread gets CPU to start running again the condition might not hold, so it's always better to check condition in loop before proceeding.
synchronized (obj) {
while (condition does not hold)
obj.wait(); // (Releases lock, and reacquires on wakeup)
... // Perform action appropriate to condition
}


3.What is busy spin? Why should you use it?

Busy spin is one of the technique to wait for events without releasing CPU. It's often done to avoid losing data in CPU cached which is lost if the thread is paused and resumed in some other core.
So, if you are working on low latency system where your order processing thread currently doesn't have any order, instead of sleeping or calling wait(), you can just loop and then again check the queue for new messages.
It's only beneficial if you need to wait for a very small amount of time

4. What's the difference between "a == b" and "a.equals(b)"?

The a = b does object reference matching if both a and b are an object and only return true if both are pointing to the same object in the heap space,
On the other hand, a.equals(b) is used for logical mapping and its expected from an object to override this method to provide logical equality.

5.What is a.hashCode() used for? How is it related to a.equals(b)?

hashCode() method returns an int hash value corresponding to an object. It's used in hash based collection classes e.g Hashtable, HashMap, LinkedHashMap and so on.
According to Java specification, two objects which are equal to each other using equals() method must have same hash code.


6.Difference between final, finalize and finally?

The final is a modifier which you can apply to variable, methods and classes.
If you make a variable final it means its value cannot be changed once initialized.
finalize is a method, which is called just before an object is a garbage collected, giving it last chance to resurrect itself, but the call to finalize is not guaranteed.
finally is a keyword which is used in exception handling along with try and catch. the finally block is always executed irrespective of whether an exception is thrown from try block or not.

7.What is a compile time constant in Java? What is the risk of using it?

public static final variables are also known as a compile time constant, the public is optional there. They are replaced with actual values at compile time because compiler know their value up-front and also knows that it cannot be changed during run-time.
One of the problem with this is that if you happened to use a public static final variable from some in-house or third party library and their value changed later than your client will still be using old value even after you deploy a new version of JARs.
To avoid that, make sure you compile your program when you upgrade dependency JAR files.


#javainterviewquestion #finally #wiprointerviewexperience #wiprointerview #infosysinterview
#infosysinterviewquestions #tcsinterview #javatutorial #javainterviewquestionsandanswersforfreshers #javainterviewquestionsandanswers
#java8

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Latest Java Interview Questions And Answers for fresher and experience |

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

2024 Top 10 Java String Interview Questions and coding problems | palindrome |reverse | anagram

2024 Top 10 Java String Interview Questions and coding problems | palindrome |reverse | anagram

Top 50 Java Interview Questions | Java Interview Questions & Answers | Java Interview Questions PDF

Top 50 Java Interview Questions | Java Interview Questions & Answers | Java Interview Questions PDF

How to Start Coding | Programming for Beginners | Learn Coding | Intellipaat

How to Start Coding | Programming for Beginners | Learn Coding | Intellipaat

Wave Optics - Class XII

Wave Optics - Class XII

США заявили о победе Украины / Президент резко изменил план

США заявили о победе Украины / Президент резко изменил план

Java Swing For Beginners | What is Java Swing | Java Swing Tutorial | Intellipaat

Java Swing For Beginners | What is Java Swing | Java Swing Tutorial | Intellipaat

КАСЬЯНОВ:

КАСЬЯНОВ: "Я видел это своими глазами. Это не публиковалось": что показали Путину, чего он боится

Comedy Club: Курсы альфа-самца | Кравец, Шальнов, Бутусов @ComedyClubRussia

Comedy Club: Курсы альфа-самца | Кравец, Шальнов, Бутусов @ComedyClubRussia

Java Collections Tutorial

Java Collections Tutorial

БЫКОВ заплакал в эфире. Самый личный выпуск: о войнах, ошибках прошлого, шансах выжить и доме

БЫКОВ заплакал в эфире. Самый личный выпуск: о войнах, ошибках прошлого, шансах выжить и доме

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]