SóProvas


ID
898093
Banca
CESGRANRIO
Órgão
BNDES
Ano
2013
Provas
Disciplina
Programação
Assuntos

Sejam as seguintes classes Java, que ocupam arquivos distintos:

-------------------- arquivo CA01.java --------------------
package M1;
public class CA01 {
      protected void mt01(int a) { }
}

-------------------- arquivo CA02.java --------------------
package M2;
import M1.*;
public class CA02 extends CA01{
    public void mt01(int a,int b){ }
    public void mt01(int a){ }
}


-------------------- arquivo CA03.java --------------------
package M1.M2;
public class CA03 {
    public double mt03(double b) { return 0.0;}
}


-------------------- arquivo CA04.java --------------------
public class CA04 {
    protected String mt04(String a,String b) { return a+ʹʹ-ʹʹ+b;}
}
A classe Q03 contém o método main(). Ela é mostrada a seguir:
import M2.*;
import M1.*;
    public class Q03 {
        public static void main(String[] args) {
              CA02 p=new CA02();
              CA01 q=new CA01();
              M1.M2.CA03 r=new CA03();
              String n=(new CA04()).mt04(ʹʹBrasilʹʹ,ʹʹBrasíliaʹʹ);
              p.mt01(2,2);
              p.mt01(7);
        }
}

Qual comando de main() produz um erro de compilação?

Alternativas
Comentários
  • Para referência dos modificadores de acesso

    http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

  • Interessante destacar a documentação do Java:


    Apparent Hierarchies of Packages

    At first, packages appear to be hierarchical, but they are not. For example, the Java API includes a java.awt package, a java.awt.color package, a java.awt.font package, and many others that begin with java.awt. However, the java.awt.color package, the java.awt.font package, and other java.awt.xxxx packages are not included in the java.awt package. The prefix java.awt (the Java Abstract Window Toolkit) is used for a number of related packages to make the relationship evident, but not to show inclusion.

    Importing java.awt.* imports all of the types in the java.awt package, but it does not import java.awt.color, java.awt.font, or any other java.awt.xxxx packages. If you plan to use the classes and other types in java.awt.color as well as those in java.awt, you must import both packages with all their files: