You can learn Java with me as the Java Programming language is being made easily. It would take a period of minimum three months and maximum 6 months to master Java. I would recommend you to watch all my videos to crack any software interviews that would require Java Programming language as a primary skill.
control flow of static and instance context in Java:-
=========================================================
1. static context:-
==================
static blocks and static variables are automatically recognized and executed at the time of loading the .class file to the JVM.
However, the static methods are executed only during the method call.
Please be informed that the .class file will be loaded inside the JVM only once. At the time of loading the .class file, the static variables and blocks will get recognized and executed automatically.
2. instance context:-
=====================
The instance variables and blocks are recognized and executed before executing the respective class constructor.
However, the instance methods are recognized and executed at the time of method call with the object reference.
Please be informed that the instance methods and blocks will be recognized and executed every time the respective class constructors are called.
Examples:-
=========
package xyz;
public class Test
{
static int a=method1();
static int method1()
{
System.out.println(" M1");
return 1000;
}
static{
System.out.println("S A 1");
}
static{
System.out.println("S A 2");
}
public static void main(String[] args)
{
}
}
Examples:-
========
package xyz;
class C{
static{
System.out.println("S B C");
}
}
class A extends C
{
static{
System.out.println("S B A");
}
}
public class Test extends A
{
static{
System.out.println("S B");
}
public static void main(String[] args)
{
}
}
Examples:-
=========
package xyz;
public class Test
{
static{
System.out.println("S B");//It will be recognized at the time of loading the .class //file to the JVM
}
{
System.out.println("I B");//Before the respective class constructor
}
Test()
{
System.out.println("T Con ");
}
public static void main(String[] args)
{
new Test();
new Test();
}
}
En esta página del sitio puede ver el video en línea static context and instance context control flow in Java the complete explanation de Duración hora minuto segunda en buena calidad , que subió el usuario Learn Java 19 abril 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 161 veces y le gustó 5 a los espectadores. Disfruta viendo!