Look at the code below and please help me solve the trick.
class TestTrick{
public static void main(String args[])
{
}
static marker()
{
System.out.println("programe executed");
}
}
The result required from this program is that the program should print
program executed
, meaning that the marker
method should be executed. But there are some rules:
It's been three days and I am unable to solve the problem because I am not a Java programmer. I have searched everything on internet to get a clue but I failed. Please someone help me run this program by strictly following the rules.
Explanation: The output of the Java compiler is bytecode, which leads to the security and portability of the Java code. It is a highly developed set of instructions that are designed to be executed by the Java runtime system known as Java Virtual Machine (JVM).
I think what they're looking for is a static initializer.
static {
marker();
}
This gets run when the class is loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With