Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
Java Class Requirements

In the following problem,

1. Which of the following is true regarding Java classes?
a) All classes must have 1 parent but may have any number of children (derived or extended) classes.
b) All classes must have 1 child (derived or extended) class but may have any number of parent classes.
c) All classes must have 1 parent class and may have a single child (derived or extended) class. d) All classes can have any number (0 or more) of parent classes and any number of children (derived or extended) classes.
e) All classes can have either 0 or 1 parent class and any number of children (derived or extended) classes.

I believed the answer would be e). I thought this because all classes can have at most 1 parent class or at least 0 (the Object class has no parent class). Furthermore, you can have any number of children (assuming integers greater than or equal to 0). The correct answer was a):

All classes must have 1 parent but may have any number of children (derived or extended) classes.

Does this mean that you can't consider the Object class to be a class?

Does the Object class have a parent?

Also, I recently asked another question on Java, also from this series of assignments (actually an optional test-review, not homework). Sorry for the two posts, but I didn't think it followed correct etiqutte to combine the questions into one post.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Technically speaking, neither A nor E is correct. The Object class is unique in having no parent; every other class must have exactly one parent. Thus, it is neither true that every class must have a parent -- Object does not -- nor is it true that all classes can have zero parents -- only Object is allowed do that.

However, if we restrict the question to user-defined classes -- leaving the special case of Object out of the picture -- answer A is correct.

about 4 years ago · Santiago Trujillo Relatório

0

The question seems to be a bit misleading. (e) seems to be the closest to the correct. The following concepts can help in understanding the question better:

  • Object class is the superclass of all the Java classes.
  • Java does not support multiple inheritance
  • Multiple Inheritance can be achieved in Java using interfaces.
  • Interfaces are not classes
  • A class which is not final can be subclassed by any number of Java classes
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda