失效链接处理 |
最C业笔试面试题大全 PDF 下蝲
本站整理下蝲Q?/strong>
链接Q?a target="_blank">https://pan.baidu.com/s/1BOmsv4tSMa14Cinycp92eQ
提取码:(x)r6w5
相关截图Q?/strong>
![]()
主要内容Q?/strong>
1.1 选择?/div>
1.1.1java 基础
1. 下面中哪两个可以?A 的子cM使用Q( Q?/div>
class A {
protected int method1 (int a, int b) {
return 0;
} }
A. public int method 1 (int a, int b) { return 0; }
B. private int method1 (int a, int b) { return 0; }
C. private int method1 (int a, long b) { return 0; }
D. public short method1 (int a, int b) { return 0; }
解答QAC
主要考查子类重写父类的方法的原则; BQ子c重写父cȝҎ(gu)Q访问权限不能降低;
CQ属于重载;DQ子c重写父cȝҎ(gu) q回值类型要相同或是父类Ҏ(gu)q回值类型的子类?/div>
2. Abstract method cannot be static. True or False ?
A. True
B. False
解答QA
抽象Ҏ(gu)可以在子cM被重写,但是静态方法不能在子类中被重写Q静态方法和静态属
性与对象?无关的,只与cL养Iq与 abstract 是矛盄Q所?abstract 是不能被修饰
?staticQ否则就 失去?abstract 的意义了
3.What will be the output when you compile and execute the following program.
class Base
{
void test() {
System.out.println("Base.test()");
} }
public class Child extends Base {
void test() { System.out.println("Child.test()");}
static public void main(String[] a) {
Child anObj = new Child();
Base baseObj = (Base)anObj;
baseObj.test();
} }
Select most appropriate answer.
A. Child.test() Base.test()
B. Base.test() Child.test()
C. Base.test()
D. Child.test()
解答QD
试代码相当于:(x)Base baseObj = new Child();父类的引用指向子cȝ实例Q子cd重写
了父c??test Ҏ(gu)Q因此调用子cȝ test Ҏ(gu)?/div>
4.What will be the output when you compile and execute the following program.
class Base{
static void test() { System.out.println("Base.test()");
}}
public class Child extends Base {
void test() { System.out.println("Child.test()"); Base.test(); //Call the parent method
}
static public void main(String[] a) {
new Child().test();
}}
Select most appropriate answer.
A. Child.test() Base.test()
B. Child.test() Child.test()
5 / 237
6 / 237
C. Compilation error. Cannot override a static method by an instance method
D. Runtime error. Cannot override a static method by an instance method
解答QC
静态方法不能在子类中被重写?/div>
5.What will be the output when you compile and execute the following program.
public class Base{
private void test() {
System.out.println(6 + 6 + "(Result)");
}
static public void main(String[] a) {
new Base().test();
}}
Select most appropriate answer.
A. 66(Result)
B. 12(Result)
C. Runtime Error.Incompatible type for +. Can't convert an int to a string.
D. Compilation Error.Incompatible type for +. Can't add a string to an int.
解答QB
字符串与基本数据cd链接的问?如果W一个是字符串那么后l就都按字符串处理,
比如上边例子??System.out.println("(Result)"+6 + 6 );那么l果是(Result)66Q如果第一
个和W二个。。?W?n 个都是基本数据第 n+1 是字W串cdQ那么前 n 个都按加法计?/div>
出结果在与字W串q接
6..What will be the output when you compile and execute the following program. The symbol ’? ’
means space.
1:public class Base{
2:
3: private void test() {
4:
5: String aStr = "? One? ";
6: String bStr = aStr;
7: aStr.toUpperCase();
8: aStr.trim();
9: System.out.println("[" + aStr + "," + bStr + "]");
7 / 237
10: }
11:
12: static public void main(String[] a) {
13: new Base().test();
14: } 15: }
Select most appropriate answer.
A. [ONE,? One? ]
B. [? One? ,One]
C. [ONE,One] D [ONE,ONE]
E. [? One? ,? One? ]
解答QE
通过 String bStr = aStr;q句代码?bStr ?aStr 指向同一个地址I间Q所以最?aStr
?bStr 的结 果应该是一PString cL定长字符Ԍ调用一个字W串的方法以后会(x)形成一
个新的字W串?/div>
7.下面关于变量?qing)其范围的陈q哪些是不正的Q?Q:(x)
|