Android模拟笔试题

一、Java选择填空题(每题3分,共30分)
1、 有如下变量定义:
int a = 3 ;请问如何转换成Integer对象?用代码实现。

2、 请写出运行结果:
class Maintester
{
 private void change(User user){
     User aUser = new User();
  aUser.setName("zhangsan");
  user.setName("lisi");
  System.out.println(user.getName());
  user = aUser;
     System.out.println(user.getName());
 
 }
 public static void main(String[] args)
 {
  User user = new User();
  user.setName("wangwu");
  Maintester  testUtils = new Maintester();
  testUtils.change(user);
  System.out.println(user.getName());
 }
}

3、 下面哪行会编译报错?
1. byte a1 = 2 , a2 = 4, a3 ;
2. short s = 16 ;
3. a2 = s ;
4. a3 = a1 * a2 ;
A、 Line 2 and Line 4
B、 Line 1 only
C、 Line 3 only
D、 Line 4 only
E、 Line 1 and Line 4

4、 写出运行结果
class A
{
 public void print(Object o){

      System.out.println("hello A");    
 }
}
class B extends A
{
 public void print(String s){

       System.out.println("Hello B-s");

 }
 public void print(Object o){

        System.out.println("Hello B-o");
 }
 public static void main(String[] args)
 {
  A a = new A();
  A b = new B();
  Object o = "123";
  b.print(o);
  a.print(o);
  String s = "abc";
  a.print(s);  
 }
}


5、 阅读以下代码并答题
public static void main(String[] args)
 {
  String a = "ab";
  String b = "cd";
  String c = "abcd";
  String d = "ab" + "cd";
  System.out.println(d==c);
        String e = a + b;
  System.out.println(e == c);
  System.out.println(e.equals(c));
 }
 
6、 阅读以下代码
public static void main(String[] args)
 {
  int i = 1,j = 10;
  do{
              if(i++ > --j){
                 continue;
     }
      
  }while(i < 5);
  System.out.println("i = " + i + "and j = "+j);
 }
输出的结果是 (   )
A. i = 6  and  j = 5
B. i = 5  and  j = 5
C. i = 6  and  j = 5
D. i = 5  and  j = 6
E. i = 6  and  j = 6

7、下列说法正确的是(     )
关键字extends
A. 可用于一个类继承一个类
B. 可用于一个接口继承一个接口
C. 可用于一个类继承一个接口
D. 可用于一个接口继承一个类

8、下面选项哪两个是java的关键字(     )
A. run
B.   import
C.   default
D.   implement

9、阅读下面代码并答题
 public class ConstOver {
      public ConstOver ( int x , int y , int z) {  }
  }
下面哪两项重载了该构造函数
A. ConstOver( ) {  }
B. Protected int ConstOver( ) {  }
C. Private ConstOver(int x ,int y , byte z ) {    }
D. Public Object ConstOver(int x ,int y,int z) {    }
E. Public void ConstOver(byte x,byte y,byte z){    }

10、Math.round(11.5)等于多少?Math.round(-11.5)等于多少?


二、Java编程题(每题11分,共22分)
1、 已有定义:String str = “6,9,4,3,8,11”;
写一段程序,以“,”作为分隔符对字符串进行分割,并按从大到小的顺序排序输出。

2、 写一个Class,实现Singleton模式

三、Android基础题目(每题4分,共36分)
1、 android的四大功能组件是________,__________,__________,___________。
2、 android的系统架构是android,__________虚拟机和___________操作系统。
3、 在Activity的_________状态和________情况下,系统可能会回收Activity。
4、 ActivityA中的某个Button的onClick()事件中执行了如下的方法:
Intent intent = new Intent(this,ActivityB.class);
startActivity(intent);
然后在ActivityB中的某个Button的onClick()事件中执行了如下的方法:
finish();
请问:ActivityA和ActivityB分别触发了其生命周期的生命事件?回答格式举例如下:
ActivityA.onXXX() ---> AcitvityA.onYYY() ----> ActivityB.onXXX() ---->ActivityA.onZZZ()。
5、 android中常用的Layout有____________,_____________,_____________,______________,______________。
6、 Android可以用__________、文件系统、__________、___________和___________来存储数据。
7、 已经把数据放入Bundle,
Intent intent = new Intent() ;
intent.setClass(this,ActivityX.class) ;
Bundle bundle = new Bundle() ;
bundle.putString(“KEY_HEIGHT”,field_heigth.getText().toString()) ;
bundle.putString(“KEY_WEITHT”,field_weight.getText().toString()) ;
intent.putExtras(bundle);
startActivity(intent);
请问在ActivityX的onCreate()事件中,如何从Bundle中取”KEY_HEIGHT”和”KEY_WEIGHT”的值?请用代码作答。

8、 在AndroidManifest.xml中的
<uses-permission android:name=”android.permission.INTERNET”/>
<uses-permission android:name=”android.permission.CAMERA”/>
指应用程序获得________权限和_________权限。


9、 在AndroidManifest.xml中
<intent-filter>
  <action android:name=”android.intent.action.MAIN”/>
  <category android:name=”android.intent.category.LAUNCHER”/>
</intent-filter>
其中”android.intent.action.MAIN”和”android.intent.category.LAUNCHER”各代表什么意思?


四、数据库知识(每题3分,共12分)
员工信息表 user_info
Id
int Name
varchar(20) Age
varchar(3) Birthday
date
1 张三 27 1982-11-21
2 李四 28 1981-09-12
3 王五 29 1980-02-07
4 赵六 29 1980-03-11

员工迟到信息表user_late
Id
int Userid
int Latedate
date
1 1 2008-11-03
2 1 2008-11-04
3 3 2008-11-05
4 4 2008-11-06
根据以上两张表的信息,完成以下问题:
1、 查询张三的年龄
2、 找出1981年10月之前出生的员工
3、 更新李四的年龄为29岁
4、 找出迟到两次以上的员工ID

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值