Buscar

Can we declare the main method of a class as private in Java? The main method in Java must be public static in order to run any application correc...

Can we declare the main method of a class as private in Java?

The main method in Java must be public static in order to run any application correctly.
If the main method is declared as private, the code will not get executed and will give a runtime error.
a) Only statement 1 is true.
b) Only statement 2 is true.
c) Both statements are true.
d) Both statements are false.

Essa pergunta também está no material:

23 pág.

Linguagem de Programação Java Universidade PaulistaUniversidade Paulista

💡 1 Resposta

User badge image

Ed Verified user icon

No, we cannot declare the main method of a class as private in Java. The main method must be declared as public static in order to run any application correctly. If the main method is declared as private, the code will not get executed and will give a runtime error. Therefore, the correct answer is option d) Both statements are false.

0
Dislike0

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

✏️ Responder

SetasNegritoItálicoSublinhadoTachadoCitaçãoCódigoLista numeradaLista com marcadoresSubscritoSobrescritoDiminuir recuoAumentar recuoCor da fonteCor de fundoAlinhamentoLimparInserir linkImagemFórmula

Para escrever sua resposta aqui, entre ou crie uma conta

User badge image

Outros materiais