There are two classes that are declared in the file.
That will be displayed after the launch?

class Singleton {
	private static Singleton s = new Singleton();
	protected Singleton() {
	public static Singleton getInstance() {
		return s;
public class Test {
	public void method() {
	public static void main(String [] str) {
		new Test();

Initialization of static fields is done during the initialization of the class. The initialization of the class in its turn is performed at the first reference to the class (creation of the exemplar of the class, a call to the static field or method, etc.)

More details about the initialization of classes can be found in the Java Language Specification:

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Зарегистрируйся сейчас
или Подпишись на будущие тесты