O GoConqr está de visual novo! Conte para nós o que você achou.

Quiz

Джава

Еркебұлан Шолпанкул 40 perguntas

Fazer o quiz

Perguntas do quiz (40)

  1. 1 What modifiers are implicitly applied to all interface methods? (Choose all that apply)
    1. Aprotected
    2. Bpublic
    3. Cstatic
    4. Dvoid
    5. Eabstract
    6. Fdefault
  2. 2What is the output of the following code?
    1: class Mammal {
    2: public Mammal(int age) {
    3: System.out.print("Mammal");
    4: }
    5: }
    6: public class Platypus extends Mammal {
    7: public Platypus() {
    8: System.out.print("Platypus");
    9: }
    10: public static void main(String[] args) {
    11: new Mammal(5);
    12: }
    13: }
    1. APlatypus
    2. BMammal
    3. CPlatypusMammal
    4. DMammalPlatypus
    5. EThe code will not compile because of line 8.
    6. FThe code will not compile because of line 11.
  3. 3Which of the following statements can be inserted in the blank line so that the code will
    compile successfully? (Choose all that apply)
    public interface CanHop {}
    public class Frog implements CanHop {
    public static void main(String[] args) {
    frog = new TurtleFrog();
    }
    }
    public class BrazilianHornedFrog extends Frog {}
    public class TurtleFrog extends Frog {}
    1. AFrog
    2. BTurtleFrog
    3. CCanHop
    4. DObject
    5. EBrazilianHornedFrog
  4. 4Which statement(s) are correct about the following code? (Choose all that apply)
    public class Rodent {
    protected static Integer chew() throws Exception {
    System.out.println("Rodent is chewing");
    return 1;
    }
    }
    public class Beaver extends Rodent {
    public Number chew() throws RuntimeException {
    System.out.println("Beaver is chewing on wood");
    return 2;
    }
    }
    1. AIt will compile without issue.
    2. BIt fails to compile because the type of the exception the method throws is a subclass of
      the type of exception the parent method throws.
    3. CIt fails to compile because the return types are not covariant.
    4. DIt fails to compile because the method is protected in the parent class and public in
      the subclass.
    5. EIt fails to compile because of a static modifier mismatch between the two methods.
  5. 5Which of the following may only be hidden and not overridden? (Choose all that apply)
    1. Aprivate instance methods
    2. Bprotected instance methods
    3. Cpublic instance methods
    4. Dstatic methods
    5. Epublic variables
    6. Fprivate variables
  6. 6Choose the correct statement about the following code:
    1: interface HasExoskeleton {
    2: abstract int getNumberOfSections();
    3: }
    4: abstract class Insect implements HasExoskeleton {
    5: abstract int getNumberOfLegs();
    6: }
    7: public class Beetle extends Insect {
    8: int getNumberOfLegs() { return 6; }
    9: }
    1. AIt compiles and runs without issue.
    2. BThe code will not compile because of line 2.
    3. CThe code will not compile because of line 4.
    4. DThe code will not compile because of line 7.
    5. EIt compiles but throws an exception at runtime.
  7. 7Which of the following statements about polymorphism are true? (Choose all that apply)
    1. AA reference to an object may be cast to a subclass of the object without an explicit cast.
    2. BIf a method takes a superclass of three objects, then any of those classes may be passed as a parameter to the method.
    3. CA method that takes a parameter with type java.lang.Object will take any reference.
    4. DAll cast exceptions can be detected at compile-time.
    5. EBy defining a public instance method in the superclass, you guarantee that the specific
      method will be called in the parent class at runtime.
  8. 8Choose the correct statement about the following code:
    1: public interface Herbivore {
    2: int amount = 10;
    3: public static void eatGrass();
    4: public int chew() {
    5: return 13;
    6: }
    7: }
    1. AIt compiles and runs without issue.
    2. BThe code will not compile because of line 2.
    3. CThe code will not compile because of line 3.
    4. DThe code will not compile because of line 4.
    5. EThe code will not compile because of lines 2 and 3.
    6. FThe code will not compile because of lines 3 and 4.
  9. 9Choose the correct statement about the following code:
    1: public interface CanFly {
    2: void fly();
    3: }
    4: interface HasWings {
    5: public abstract Object getWindSpan();
    6: }
    7: abstract class Falcon implements CanFly, HasWings {
    8: }
    1. AIt compiles without issue.
    2. BThe code will not compile because of line 2.
    3. CThe code will not compile because of line 4.
    4. DThe code will not compile because of line 5.
    5. EThe code will not compile because of lines 2 and 5.
    6. FThe code will not compile because the class Falcon doesn’t implement the interface
      methods.
  10. 10Which statements are true for both abstract classes and interfaces? (Choose all that apply)
    1. AAll methods within them are assumed to be abstract.
    2. BBoth can contain public static final variables.
    3. CBoth can be extended using the extend keyword.
    4. DBoth can contain default methods.
    5. EBoth can contain static methods.
    6. FNeither can be instantiated directly.
    7. GBoth inherit java.lang.Object.

Informações

Descrição
Quiz sobre Джава, criado por Еркебұлан Шолпанкул em 22-12-2018.
Idioma
English
Visualizações
8
Avaliação
Ainda sem avaliações
Avalie este quiz
Avalie este quiz

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?