私は講義から次の質問を受けて、回答がiii.It compiles, runs and prints the string “Hello”
だと答えましたが、回答はi. It has a compilation error
だと信じています。輸入packA.AまたはpackAする必要があります* 私の質問をされて - 。これはタイプミスであるか、これはまだクラスを指定しないインポートパッケージ
J. Assuming the class A and class B given below are defined in different packages, packA and packB.
package packA;
public class A {
protected void msg() {
System.out.println("Hello");
}
}
package packB;
import packA;
class B extends A {
public static void main(String[] args) {
B obj = new B();
obj.msg();
}
}
which of the following is correct about the class B?
i. It has a compilation error
ii. It has a run time error
iii.It compiles, runs and prints the string “Hello”
iv. None of the above
TRY IT YOURSELF。 –
なぜ叫び声ですか?!?!?!?!?!?!?!?!?!?! – Turing85
私はそれを試してみましたが、 "import packA.A"または "import packA。*"をクラスBに指定しない限り、プログラムを実行することはできませんが、これが絶対に正しいかどうかはまだ分かりません。私は静かではないここにキャッチしていますか?または、おそらく私は正しいとこれは実際にはタイプミスですか? –