Java学习者论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

恭喜Java学习者论坛(https://www.javaxxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,购买链接:点击进入购买VIP会员
JAVA高级面试进阶视频教程Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程

Go语言视频零基础入门到精通

Java架构师3期(课件+源码)

Java开发全终端实战租房项目视频教程

SpringBoot2.X入门到高级使用教程

大数据培训第六期全套视频教程

深度学习(CNN RNN GAN)算法原理

Java亿级流量电商系统视频教程

互联网架构师视频教程

年薪50万Spark2.0从入门到精通

年薪50万!人工智能学习路线教程

年薪50万!大数据从入门到精通学习路线年薪50万!机器学习入门到精通视频教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程 MySQL入门到精通教程
查看: 358|回复: 0

本人新手 求解答

[复制链接]

该用户从未签到

发表于 2015-10-22 22:49:06 | 显示全部楼层 |阅读模式
3Java金币
  • 1.

    程序执行的结果是:()。
    01
    public class Point{

    [backcolor=rgb(248, 248, 248) !important]
    02
    int y = 7;

    03
    public void step(int y) {

    [backcolor=rgb(248, 248, 248) !important]
    04
        y += y;

    05
       System.out.println(y);

    [backcolor=rgb(248, 248, 248) !important]
    06
    }

    07
    public static void main(String[] args) {

    [backcolor=rgb(248, 248, 248) !important]
    08
       Point p = new Point();

    09
       p.step(10);

    [backcolor=rgb(248, 248, 248) !important]
    10
    }

    11
    }




    • A.14
    • B.20
    • C.10
    • D.17

  • 2.

    程序的执行结果是:()。
    01
    public class Question {

    [backcolor=rgb(248, 248, 248) !important]
    02
        private int  num;

    03
        public static void main(String [] args){

    [backcolor=rgb(248, 248, 248) !important]
    04
            Question q = new Question();

    05
            q.num=13;

    [backcolor=rgb(248, 248, 248) !important]
    06
            update(q);

    07
            System.out.println(q.num);

    [backcolor=rgb(248, 248, 248) !important]
    08
        }

    09
       public static void update(Question q){

    [backcolor=rgb(248, 248, 248) !important]
    10
            q.num=9;

    11
        }

    [backcolor=rgb(248, 248, 248) !important]
    12
    }




    • A.13
    • B.9
    • C.0
    • D.4

  • 3.

    程序执行的结果是:()。
    01
    public class Answer {

    [backcolor=rgb(248, 248, 248) !important]
    02
    public static void main(String[] args) {

    03
        int score = 20;

    [backcolor=rgb(248, 248, 248) !important]
    04
       Answer  ans= new Answer();

    05
       ans.add(score);

    [backcolor=rgb(248, 248, 248) !important]
    06
       System.out.println(" main: score = " + score);

    07
    }

    [backcolor=rgb(248, 248, 248) !important]
    08
    void  add(int score) {

    09
       System.out.println(" add: score=" + score++);

    [backcolor=rgb(248, 248, 248) !important]
    10
    }

    11
    }




    • A.[backcolor=rgb(255, 255, 255) !important]
      1
      add: score=21

      [backcolor=rgb(248, 248, 248) !important]
      2
      main: score = 21



    • B.[backcolor=rgb(255, 255, 255) !important]
      1
      add: score=20

      [backcolor=rgb(248, 248, 248) !important]
      2
      main: score = 21



    • C.[backcolor=rgb(255, 255, 255) !important]
      1
      add: score=21

      [backcolor=rgb(248, 248, 248) !important]
      2
      main: score = 20



    • D.[backcolor=rgb(255, 255, 255) !important]
      1
      add: score=20

      [backcolor=rgb(248, 248, 248) !important]
      2
      main: score = 20





  • 4.

    下列代码编译或运行的结果是:()。
    01
    public class  Snow{

    [backcolor=rgb(248, 248, 248) !important]
    02
    public String  jump(int x, int y) {

    03
        return "jump one";

    [backcolor=rgb(248, 248, 248) !important]
    04
    }

    05
    public String jump(int[] vals) {

    [backcolor=rgb(248, 248, 248) !important]
    06
        return "jump two";

    07
    }

    [backcolor=rgb(248, 248, 248) !important]
    08
    public static void main(String[] args) {

    09
        Snow s=new Snow();

    [backcolor=rgb(248, 248, 248) !important]
    10
        System.out.println(s.jump(4, 5));

    11
    }

    [backcolor=rgb(248, 248, 248) !important]
    12
    }




    • A.public String jump(int[] vals) {行,编译出错
    • B.System.out.println(s.jump(4, 5));行,抛出运行时异常
    • C.输出:jump one
    • D.输出:jump two

  • 5.

    关于下列代码说法正确的是:()。
    01
    public class  storm {

    [backcolor=rgb(248, 248, 248) !important]
    02
    public void  find() {

    03
    }

    [backcolor=rgb(248, 248, 248) !important]
    04
    public String find() {

    05
      return "find";

    [backcolor=rgb(248, 248, 248) !important]
    06
    }

    07
    public double find(int x) {

    [backcolor=rgb(248, 248, 248) !important]
    08
      return 2.0;

    09
    }

    [backcolor=rgb(248, 248, 248) !important]
    10
    }




    • A.无编译错误
    • B.代码 public String find() { 行,出现编译错误
    • C.代码 public double find(int x) {行,出现编译错误
    • D.代码 return "find";行处出现编译错误

  • 6.

    请看下列代码:
    01
    class ClassA {}

    [backcolor=rgb(248, 248, 248) !important]
    02
    class ClassB extends ClassA {}

    03
    class ClassC extends ClassA {}

    [backcolor=rgb(248, 248, 248) !important]
    04
    public class Test{

    05
    public static void main(String[] args) {

    [backcolor=rgb(248, 248, 248) !important]
    06
      ClassA p0 = new ClassA();

    07
      ClassB p1 = new ClassB();

    [backcolor=rgb(248, 248, 248) !important]
    08
      ClassC p2 = new ClassC();

    09
      ClassA p3 = new ClassB();

    [backcolor=rgb(248, 248, 248) !important]
    10
      ClassA p4 = new ClassC();

    11
      <插入代码>

    [backcolor=rgb(248, 248, 248) !important]
    12
    }

    13
    }



    下列选项中放置在<插入代码>处,使程序编译正确的是:()。
    • A.p0 = p1;
    • B.p1 =p2;
    • C.p2 = p4;
    • D.p2 = (ClassC)p1;

  • 7.

    下列代码的运行结果是:()。
    01
    public class Animal {

    [backcolor=rgb(248, 248, 248) !important]
    02
    public String noise() {

    03
      return "Animal";

    [backcolor=rgb(248, 248, 248) !important]
    04
    }

    05
    public static void main(String[] args) {

    [backcolor=rgb(248, 248, 248) !important]
    06
      Cat cat = null;

    07
      Animal animal = new Dog();

    [backcolor=rgb(248, 248, 248) !important]
    08
      if (animal instanceof Cat) {

    09
       cat = (Cat) animal;

    [backcolor=rgb(248, 248, 248) !important]
    10
       System.out.println(cat.noise());

    11
      } else {

    [backcolor=rgb(248, 248, 248) !important]
    12
       System.out.println("animal is not Cat's instance");

    13
      }

    [backcolor=rgb(248, 248, 248) !important]
    14
    }

    15
    }

    [backcolor=rgb(248, 248, 248) !important]
    16
    class Dog extends Animal {

    17
    public String noise() {

    [backcolor=rgb(248, 248, 248) !important]
    18
      return "Dog";

    19
    }

    [backcolor=rgb(248, 248, 248) !important]
    20
    }

    21
    class Cat extends Animal {

    [backcolor=rgb(248, 248, 248) !important]
    22
    public String noise() {

    23
      return "Cat";

    [backcolor=rgb(248, 248, 248) !important]
    24
    }

    25
    }




    • A.Animal
    • B.Dog
    • C.Cat
    • D.animal is not Cat's instance

  • 8.

    请看下列代码编译和运行的结果是:()。
    1
    public class Teacher {

    [backcolor=rgb(248, 248, 248) !important]
    2
    private String name="sun";

    3
    public static void main(String[] args) {

    [backcolor=rgb(248, 248, 248) !important]
    4
      Teacher[] teachers=new Teacher[2];

    5
      System.out.println(teachers[0].name);

    [backcolor=rgb(248, 248, 248) !important]
    6
      System.out.println(teachers.length);

    7
    }

    [backcolor=rgb(248, 248, 248) !important]
    8
    }




    • A.sun  2
    • B.null  2
    • C.null   1
    • D.运行时抛出NullPointerException异常

  • 9.

    下列代码编译和运行的结果是:()。
    01
    class Person {

    [backcolor=rgb(248, 248, 248) !important]
    02
    String name = " ";

    03

    [backcolor=rgb(248, 248, 248) !important]
    04
    public Person(String name) {

    05
      this.name = name;

    [backcolor=rgb(248, 248, 248) !important]
    06
    }

    07
    }

    [backcolor=rgb(248, 248, 248) !important]
    08

    09
    class Employee extends Person {

    [backcolor=rgb(248, 248, 248) !important]
    10
    String empNO = "0000";

    11

    [backcolor=rgb(248, 248, 248) !important]
    12
    public Employee(String empNO) {

    13
      this.empNO = empNO;

    [backcolor=rgb(248, 248, 248) !important]
    14
    }

    15
    }

    [backcolor=rgb(248, 248, 248) !important]
    16

    17
    public class EmployeeTest {

    [backcolor=rgb(248, 248, 248) !important]
    18
    public static void main(String[] args) {

    19
      Employee e = new Employee("1109");

    [backcolor=rgb(248, 248, 248) !important]
    20
      System.out.println(e.empNO);

    21
    }

    [backcolor=rgb(248, 248, 248) !important]
    22
    }




    • A.输出:0000
    • B.输出:1109
    • C.代码public Employee(String empNO) {行,出现编译错误
    • D.抛出运行时异常

  • 10.

    下列代码编译和运行的结果是:()。
    01
    class A {

    [backcolor=rgb(248, 248, 248) !important]
    02
    public void start() {

    03
      System.out.println("A Start");

    [backcolor=rgb(248, 248, 248) !important]
    04
    }

    05
    }

    [backcolor=rgb(248, 248, 248) !important]
    06
    public class B extends A {

    07
    public void start() {

    [backcolor=rgb(248, 248, 248) !important]
    08
      System.out.println("B Start");

    09
    }

    [backcolor=rgb(248, 248, 248) !important]
    10
    public static void main(String[] args) {

    11
      ((A) new B()).start();

    [backcolor=rgb(248, 248, 248) !important]
    12
    }

    13
    }




    • A.输出:A Start
    • B.输出:B Start
    • C.输出:A Start        B Start
    • D.编译错误

  • 11.

    关于下列代码说法正确的是:()。
    01
    public interface A {

    [backcolor=rgb(248, 248, 248) !important]
    02
    public void doSomething(String thing);

    03
    }

    [backcolor=rgb(248, 248, 248) !important]
    04
    interface B {

    05
    }

    [backcolor=rgb(248, 248, 248) !important]
    06
    interface C extends A, B {

    07
    }

    [backcolor=rgb(248, 248, 248) !important]
    08
    interface D {

    09
    public void doIt(String thing);

    [backcolor=rgb(248, 248, 248) !important]
    10
    }

    11
    class AImpl implements C ,D{

    [backcolor=rgb(248, 248, 248) !important]
    12
    public void doSomething(String msg) {}

    13
    public void doIt(String thing) {}

    [backcolor=rgb(248, 248, 248) !important]
    14
    }




    • A.所有类和接口都编译成功
    • B.接口A编译失败
    • C.类AImpl编译失败
    • D.接口C编译失败

  • 12.

    java 中,关于 final 关键字的说法正确的是:()。
    • A.如果修饰局部变量,必须定义时初始化
    • B.如果修饰类,则该类只能被一个子类继承
    • C.如果修饰方法,则该方法不能在子类中被覆盖
    • D.如果修饰方法,则该方法所在的类不能被继承

  • 13.

    关于下列代码说法正确的是:()。
    01
    public class Cell {

    [backcolor=rgb(248, 248, 248) !important]
    02
    private final int id;

    03
    public Cell(int id) {

    [backcolor=rgb(248, 248, 248) !important]
    04
      this.id = id;

    05
    }

    [backcolor=rgb(248, 248, 248) !important]
    06
    public void updateId(int id) {

    07
      this.id = id;

    [backcolor=rgb(248, 248, 248) !important]
    08
    }

    09
    public static void main(String[] args) {

    [backcolor=rgb(248, 248, 248) !important]
    10
      Cell cell = new Cell(1001);

    11
      cell.updateId(1002);

    [backcolor=rgb(248, 248, 248) !important]
    12
      System.out.println(cell.id);

    13
    }

    [backcolor=rgb(248, 248, 248) !important]
    14
    }




    • A.编译错误
    • B.运行时异常抛出
    • C.运行后,cell对象属性id的值没有改变,仍然是1001
    • D.运行后,cell对象属性id的值改变成新的值1002

  • 14.

    下列选项中,不属于Java 的访问控制修饰符的是:()。
    • A.private
    • B.protected
    • C.friendly
    • D.public

  • 15.

    下面关于import, class和package的声明顺序正确的是:()。
    • A.package, import, class
    • B.class, import, package
    • C.import, package, class
    • D.package, class, import

  • 16.

    有一个名为Product的类,下列方法中属于该类的构造方法的是:()。
    • A.public Product(){}
    • B.public Product(String name){}
    • C.public void Product(){}
    • D.public void Product(String name){}

  • 17.

    请看下列代码:
    1
    public class Tetromino {

    [backcolor=rgb(248, 248, 248) !important]
    2
    protected int move(int x) {

    3
      return 0;

    [backcolor=rgb(248, 248, 248) !important]
    4
    }

    5
    }

    [backcolor=rgb(248, 248, 248) !important]
    6
    class T extends Tetromino {

    7
    <插入代码>

    [backcolor=rgb(248, 248, 248) !important]
    8
    }



    在<插入代码>处填入选项中的代码,使T类没有编译错误的是:()。
    • A.public int move(int x) { return 0; }
    • B.private int move(int x) { return 0; }
    • C.private int move(long x) { return 0; }
    • D.protected long move(int x) { return 0; }

  • 18.

    下列关于JVM的内存结构描述正确的是:()。
    • A.类的各种信息在堆中保存
    • B.栈用于存放程序运行过程当中所有的局部变量
    • C.堆一般用于存储使用new关键字创建的对象
    • D.类是JVM的内存结构

  • 19.

    请看下列代码:
    1
    public class Foo {

    [backcolor=rgb(248, 248, 248) !important]
    2
      static void alpha() { /* more code here */}

    3
      void beta() { /* more code here */}

    [backcolor=rgb(248, 248, 248) !important]
    4
    }



    下列说法正确的是:()。
    • A.Foo.beta()是调用beta方法的正确方式
    • B.Foo.alpha()是调用alpha方法的正确方式
    • C.beta方法可以直接调用alpha方法
    • D.alpha方法可以直接调用beta方法

  • 20.

    请看下列代码:
    1
    public class Line {

    [backcolor=rgb(248, 248, 248) !important]
    2
        private Point p;

    3
        public Line() {

    [backcolor=rgb(248, 248, 248) !important]
    4
            <插入代码>

    5
        }

    [backcolor=rgb(248, 248, 248) !important]
    6
    public class Point { }

    7
    }



    在<插入代码>处,需要创建Point类的对象,下列选项正确的是:()。
    • A.super.p = new  Point();
    • B.p = super.new Point();
    • C.p =new Point();
    • D.p =this.new Point()


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Java学习者论坛 ( 声明:本站资料整理自互联网,用于Java学习者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

GMT+8, 2024-4-25 00:23 , Processed in 0.450266 second(s), 44 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表