Question from the Java test

Write a Java program that prints 'Yes!'

Expert

What is the output of executing the following code?

public class Main {
	public static void main(String[] args) {
		Main m = null;
	    m.printM();
	}
	public static void printM() {
	    System.out.println("Yes!");
	}
}
Author: FodiéStatus: PublishedQuestion passed 133 times
Edit
-1
Community Evaluations
developer avatar
Incorrect answer
Ali Mohamed
01/06/2024
la bonne réponse est qu'une exception de type NullPointerException sera lancée
developer avatar
Fodié
04/06/2024
il n' y aura pas de NullPointerException car la mèthode printM() est "static".
developer avatar
Ali Mohamed
05/06/2024
Tu as raison Fodie je ne l'avais pas remarqué 👍