`
gybmike
  • 浏览: 181641 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

java自测题三

    博客分类:
  • java
阅读更多
Which statement is true about the grid bag layout manager? 
   A. The number of rows and columns is fixed when the container is created. 
   B. The number of rows and columns is fixed when the GridBagLayout object is 
        created. 
   C. If a component has a fill value of BOTH, then as the container change size, the 
        component is resized. 
     D. Every component must carry a non-zero weightx and weighty value when it is added 
        to the container 
   E. If a row has a weighty value that is non-zero, then as the container changes 
        height, the row changes height. 


请选择:  A  B  C  D  E
答案:C

Consider the following code: What will be printed?
public class Arg{
  String [] MyArg;
  public static void main(String arg[]){
   MyArg[] = arg[];
  }
 
public void amethod(){
   System.out.println(arg[1]);
}
}
A. null
B. 0
C. Nothing will be printed. Compilation error.
D. Compiles just fine, but a RuntimeException will be thrown.

请选择:  A  B  C  D
答案:C

Consider the code fragment below:
outer: for(int i = 0; i < 2; i++){
  inner: for(int j = 0; j < 2; j++){
   if(j==1)
     break outer;
     System.out.println("i = " + i ", j = " + j);
  }
}
Which of the following will be printed to standard output?
A. i = 0, j = 0
B. i = 1, j = 0
C. i = 2, j = 0
D. i = 0, j = 1
E. i = 1, j = 1
F. i = 2, j = 1

请选择:  A  B  C  D  E  F
答案:A

What access control keyword should you use to enable other classes to access a
method freely within its package, but to restrict classes outside of the package
from accessing that method? Select all valid answers.
a. private
b. public
c. protected
d. Do not supply an access control keyword (friendly).

请选择:  A  B  C  D
答案:D

 
   1)  interface Foo{ 
   2)   int k=0; 
   3)    } 
   4) public class Test implements Foo{ 
   5)  public static void main(String args[]){ 
   6)     int i; 
   7)  Test test =new Test(); 
    i=test.k; 
   9)  i=Test.k; 
  10)  i=Foo.k; 
  11)  } 
  12) } 

What is the result?
A. Compilation succeeds.
B. An error at line 2 causes compilation to fail.
C. An error at line 9 causes compilation to fail.
D. An error at line 10 causes compilation to fail.
E. An error at line 11 causes compilation to fail.
 


What will happen when you attempt to compile and run this code?
    class Test{
        abstract public void myfunc();
        public void another(){
          System.out.println("Another method");
        }
    }

     public class Abs extends Test{
        public static void main(String argv[]){
           Abs a=new Abs();
           a.amethod();
        }

        public void myfunc(){
           System.out.println("My func");
        }

        public void amethod(){
           myfunc();
        }
}

Select the one right answer.

A.The code will compile and run,printing out the words"My Func"
B.The compiler will complain that the Test class is not declared as abstract methods.
C.The code will compile but complain at run time that Test class has non
   abstract methods.
D.The compiler will complain that the method myfunc int the base class has no 
   body,nobody at all to looove it


请选择:  A  B  C  D
答案:B
点评:当类中存在一个以上的抽象方法时,该类必须被声明为抽象类,否则会发生编译错误。在本例中
,由于基类Test存在一个抽象的方法myfunc(),而该基类没有被声明为抽象类,所以在编译时产生
错误.


What will happen when you attempt to compile and run this code?
    class Test{
        abstract public void myfunc();
        public void another(){
          System.out.println("Another method");
        }
    }

     public class Abs extends Test{
        public static void main(String argv[]){
           Abs a=new Abs();
           a.amethod();
        }

        public void myfunc(){
           System.out.println("My func");
        }

        public void amethod(){
           myfunc();
        }
}

Select the one right answer.

A.The code will compile and run,printing out the words"My Func"
B.The compiler will complain that the Test class is not declared as abstract methods.
C.The code will compile but complain at run time that Test class has non
   abstract methods.
D.The compiler will complain that the method myfunc int the base class has no 
   body,nobody at all to looove it


请选择:  A  B  C  D
答案:B
点评:当类中存在一个以上的抽象方法时,该类必须被声明为抽象类,否则会发生编译错误。在本例中
,由于基类Test存在一个抽象的方法myfunc(),而该基类没有被声明为抽象类,所以在编译时产生
错误.

String foo="blue"; 
  boolean[] bar=new boolean[1]; 
   if(bar[0]){ 
      foo="green"; 
    } 
  what is the value of foo? 
   A.""  B.null  C.blue   D.green 


请选择:  A  B  C  D
答案:C


Given the following class:
  public class Sample{
  long length;
  public Sample(long l){ length = l; }
  public static void main(String arg[]){
  Sample s1, s2, s3;
  s1 = new Sample(21L);
  s2 = new Sample(21L); 
  s3 = s2;
  long m = 21L;
  }
  } 

Which expression returns true?
  A. s1 == s2;
  B. s2 == s3;
  C. m == s1;
  D. s1.equals(m).


请选择:  A  B  C  D
答案:B
点评:==操作符两边的操作数必须是同一类型的(可以是父子类之间)才能编译通过。

A public member vairable called MAX_LENGTH which is int type, the value of the variable 
remains constant value 100. Use a short statement to define the variable.
  A. public int MAX_LENGTH=100;
  B. final int MAX_LENGTH=100;
  C. final public int MAX_LENGTH=100;
  D. public final int MAX_LENGTH=100.


请选择:  A  B  C  D
答案:D
点评: Java中共有变量使用public定义,常量变量使用final,另外注意的是修饰符的顺序,一个最完整的修饰是public static final int varial_a=100;这个顺序不能错,这和c++中也是不同的。而答案c恰恰错在修饰符的顺序上。

What can you place first in this file?
//What can you put here?
public class Apa{}
A. class a implements Apa
B. protected class B {}
C. private abstract class{}
D. import java.awt.*;
E. package dum.util;
F. private int super = 1000;

请选择:  A  B  C  D  E
答案:A D E


import java.awt.*; 
   public class X extends Frame{ 
    public static void main(String[] args){ 
     X x=new X(); 
     x.pack(); 
     x.setVisible(true); 
     } 
   public X(){ 
   setLayout(new BorderLayout()); 
   Panel p=new Panel(); 
   add(p,BorderLayout.NORTH); 
   Button b=new Button("North"); 
   p.add(b); 
   Button b1=new Button("South"); 
   add(b1,BorderLayout.SOUTH); 
    } 
     which two are true? 
   A. The button labeled "North" and "South" will have the same width 
   B. The button labeled "North" and "South" will have the same height 
   C. The height of the button labeled "North" can vary if the Frame is resized 
   D. The height of the button labeled "South" can vary if the Frame is resized 
   E. The width of the button labeled "North" is constant even if the Frame is   
      resized 
   F. The width of the button labeled "South" is constant even if the Frame is 
      resized 


请选择:  A  B  C  D  E  F
答案:B E
分享到:
评论

相关推荐

    java 测试

    2. "~$va笔试题常见英语.doc" 提到了笔试题,这可能是面试或招聘过程中的Java测试题目,其中可能包含了一些与Java测试相关的英文术语或概念。 3. "SCWCD Exam Study(updated).pdf" SCWCD代表Sun Certified Web ...

    北大青鸟Y2Java结业测试题 包含源码

    【标题】北大青鸟Y2Java结业测试题 包含源码 这是一份针对北大青鸟Y2阶段Java学员的结业测试题,它旨在检验学员在学习完这一阶段课程后对Java编程语言的理解程度和应用能力。这份测试题不仅包含了一系列问题,还...

    数据结构自测题(java版)

    本套自测题集是专为Java编程语言设计的,涵盖了数据结构的基础到高级主题,适合计算机专业的在校学生进行考试复习。以下是各章自测题及详细答案的概述: 1. **数据结构绪论**: 这一部分通常会介绍数据结构的基本...

    北大青鸟S1 JAVA 选择题50题内部测试

    【北大青鸟S1 JAVA 选择题50题内部测试】是北大青鸟教育机构为学员准备的一套Java编程语言的精选选择题集,旨在帮助学员巩固和检验S1阶段的学习成果。这套试题涵盖了一小时的限时测试,旨在锻炼学员在实际考试环境中...

    测试题 Java测试题

    Java测试题 用于检测学习效果的一个小测验!

    java面试笔试资料java笔试题大集合及答案题库java笔试题汇总资料188个合集.zip

    广州传智播客JavaEE工程师测试题(带答案的).doc 应聘时最漂亮的回答.docx 当面试官问「你有什么要问我的吗」时,应该问什么?.docx 提高 Java 代码性能的各种技巧.docx 搜狗商业平台Java技术实践.docx 最新JAVA...

    java面试题集锦 java面试题集锦

    这些面试题通常用于测试开发者对Java基础知识的掌握程度。理解JDK与JRE的区别可以帮助开发者理解开发环境和运行环境的不同需求,而`==`和`equals`的使用则涉及到对Java内存模型的理解,这是编写正确、健壮的Java代码...

    Java 测试系统 (选择题的)

    Java 测试系统是一种基于Java编程语言开发的软件应用,主要用于进行选择题类型的在线测试。这样的系统通常包含多项功能,如题目库管理、用户界面、答题逻辑以及结果评估等。在这个项目中,我们可以从以下几个关键...

    JAVA基础测试题(含答案)

    这份"JAVA基础测试题(含答案)"的压缩包显然旨在帮助学习者检验和巩固他们的Java基础知识。让我们一起探讨这些测试题可能涵盖的知识点,以及这些知识点在实际编程中的重要性。 1. **Java语法基础**:测试题可能会...

    java面试笔试题库java软件设计java笔试题大集合及答案文档资料合集300MB.zip

    广州传智播客JavaEE工程师测试题(带答案的).doc 应聘时最漂亮的回答.docx 当面试官问「你有什么要问我的吗」时,应该问什么?.docx 提高 Java 代码性能的各种技巧.docx 搜狗商业平台Java技术实践.docx 最新JAVA...

    《java程序设计》期中考试测试题 含答案.doc

    "Java 程序设计期中考试测试题含答案" 本文档提供了 Java 程序设计期中考试测试题,包括选择题、填空题和编程题。测试题涵盖了 Java 基础知识点,包括 Java 源程序编译、变量、数据类型、运算符、控制语句、方法、...

    Java应用程序-题库测试题练习题带答案测试题模拟题自测题.doc

    Java应用程序-题库测试题练习题带答案测试题模拟题自测题.doc

    Java 技能测试题

    Java 技能测试题主要涵盖了三个核心领域:线程、Socket和I/O以及算法和数据库操作。这些知识点在Java编程中至关重要,对于软件工程师的角色尤其重要。以下是对这些知识点的详细解释: 1. **线程**: 线程是程序中...

    最新各大公司企业真实面试题-Java面试题

    "Java 面试题及其答案.doc"和"JAVA面试题.doc"提供了大量的面试题及解答,涵盖了从基础知识到高级特性的广泛范围,包括反射、注解、设计模式、Spring框架、数据库操作等。通过这些题目,求职者可以自我评估,了解...

    java课程期末测试题

    Java课程期末测试题通常涵盖了Java语言的基础概念、核心特性、面向对象编程、异常处理、集合框架、多线程、输入/输出(I/O)系统、网络编程、数据库连接(JDBC)以及一些高级主题如反射、注解和Java Swing图形用户界面等...

    JAVA自测题,相当于sun认证考试

    Java自测题是一种高效的学习和复习工具,尤其对于准备Sun认证考试(现在称为Oracle Certified Professional, Java SE 8 Programmer)的学员来说,它提供了一种检验自身编程技能和理论知识的方式。Sun认证是Java...

    java测试题

    "Java测试题"可能包含了一系列针对Java语言核心概念、语法、数据结构、异常处理、多线程、集合框架、IO流、网络编程以及单元测试等方面的题目。 Java测试通常分为以下几个关键部分: 1. **基本概念**:这包括了解...

Global site tag (gtag.js) - Google Analytics