正式应聘的JAVA笔试题和答案嵌入式开发怎么样
一:选择题
1:List, Set, Map是否继承自Collection接口
A:都是,B 都不是 C:List, Set 是 D:Set, Map 是
正确答案 C
2:下面描述哪个是正确的
A:构造器Constructor可被override
B:可以继承String类
C:try {}里有一个return语句,那么紧跟在这个try后的finally {}里的code不会被执行D:两个对象值相同(x.equals(y) == true),那么也有相同的hash code
正确答案 D
3 abstract的method是否可同时是static,是否可同时是native,是否可同时是synchronized A:都能 B:都不能 C:可以为static D:可以为native
正确答案 A
java常见笔试题>vlookup函数有格式要求吗4:下面的程序中,temp的最终值是什么?
long temo=(int)3.9;
temp%=2;
A: 0 B :1 C :2 D : 3
正确答案 B
5、请在以下选项中选出非基本数据类型的选项 ( )
A: int B:byte C: boolean D:String
正确答案 D
6、阅读下面代码段, 给出以下代码的输出结果
public class Test{
public static void main(String args[])
零基础学编程极客时间{
String str1 = "abc";
String str = "abc;
String str2 = new String("abc");
System.out.println(str1 == str2);
System.out.println(str1.equals(str2));
System.out.println(str == str1);
}
}
A:true,true,true B:true,false,true C:true,true,false D:false,true,true
正确答案 D
7、阅读下面代码段, 给出以下代码的输出结果:
int i=1;
switch (i) {
case 0:
System.out.println("zero");
break;
case 1:
System.out.println("one");
case 2:
System.out.println("two");
default:
System.out.println("default");tomcat虚拟主机localhost
}
A: B::D:default 正确答案 C
8、阅读下面代码段, 给出以下代码的输出结果
public class MyClass{
static int i;
public static void main(String argv[]){
System.out.println(i);
}
}
A: Error Variable i may not have been initialized B:null C:D:0 正确答案 D
9、阅读下面代码段, 给出以下代码的输出结果:
class A{
static{
System.out.print( “A1”);
}
public A(){
System.out.print( “A2”);
}
}
class B extends A{
static{
System.out.print( “B1”);
}
public B(){
System.out.print( “B2”);
}
}
public class Hello{
public static void main(String[] args){
A ab = new B();
ab = new B();
}
}
大学数据库课程设计A:A1B1A2B2B1B2 B:A1B1A2B2A2B2 C:A1B1A2B2B1B2 D:A1A2B1B2A2B2
正确答案 B
10、阅读下面代码段, 给出以下代码的输出结果
public class TestData {
public String getValue () {
String value = "";
try{
value = "test1";
return value;
}catch(Exception e){
e.printStackTrace();
}finally{
value = "test2";
}
return value;
}
public static void main(String args[]){
TestData test = new TestData();
String a = Value();
System.out.println(a);
}
}
A.test1
B.test2
C.null
D.””
正确答案 A
二、改错题,如果有错误,请指出并修正。
1、
interface A{
int x = 0;
}
class B{
int x =1;
}
class C extends B implements A {
public void pX(){
System.out.println(x);
}
public static void main(String[] args) {
new C().pX();
}
}
答案:错误。在编译时会发生错误(错误描述不同的JVM有不同的信息,意思就是未明确的x调用,两个x都匹配(就象在同时import java.util和java.sql两个包时直接声明Date一样)。对于父类的变量,可以用super.x来明确,而接口的属性默认隐含为 public static final.所以可以通过A.x来明确。
2、
class Data {
int i = 1;
}
public class TestData {
Data a1 = new Data();
final Data a2 = new Data();
final Data a21;
static final Data a3 = new Data();
public static void main(String[] args) {
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论