Day 39 | Daily Java interview question | #java #ocjp #scjp #javacertification

preview_player
Показать описание
Java programming interview questions
Java interview questions
Java programming
Java tutorial
learn Java
Java interview
springboot
#scjp #javaprogramming #javainterviewquestion #javatutorial #learnjava #interview #javaquestions #javascript #ocjp #java #javacertification #springboot #javaquestions
Рекомендации по теме
Комментарии
Автор

during program execution, the static code block will be executed when loading the class (that is, just running the program, the static code block is executed) and when reading the new Object() command;
the first step is to initialize the attribute memory cell (so int x = m1(); will be read first
so the function m1(); executed first
followed by the block of instance code to be executed (if any)
, then call the constructor
finally return the object's reference
so the order is:
in m1 method
in constructor

fantasy_.
Автор

Can someone explain constructor should trigger first right?

sujaltale
Автор

In constructor then
In method
Because that called on load everything time while in constructor

mohamedimran
Автор

In m1 method
In constructor
We are creating object then object creation means JVM will allocate memory for instance area ..

_Samar-Coding
visit shbcf.ru