SUN样题测试及答案

NEW SUN CERTIFIED PROGRAMMER FOR THE JAVA 2 PLATFORM SAMPLE QUESTIONS
1. Given:
  1. public class ArrayTest {
  2.   public static void main (String[] args) {
  3.     Object[] ov;
  4.     String[] sa = { "Green", "Blue", "Red" };
  5.     ov = sa;
  6.     System.out.println("Color = " + ov[1]);
  7.   }
  8. }

What is the result?

  1. fails to compile
  2. prints Color=Blue
  3. prints Color=Green
  4. generates an exception at runtime

2. Given:
    • public class OuterClass {
    •   private double d1 = 1.0;
    •     //insert code here
    • }

You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?(Choose two.)

    • class InnerOne{
        public static double methoda() {return d1;}
      }
    • public class InnerOne{
        static double methoda() {return d1;}
      }
    • private class InnerOne{
        double methoda() {return d1;}
      }
    • static class InnerOne{
        protected double methoda() {return d1;}
      }
  1. abstract class InnerOne{
      public abstract double methoda();
    }

3. Given:
    • public class X {
    •   public void m(Object x) {
    •     x = new Integer(99);
    •     Integer y = (Integer)x;
    •     y = null;
    •     System.out.println("x is" + x);
    •   }
    • }

When is the Integer object, created in line 3, eligible for garbage collection?

  1. never
  2. just after line 4
  3. just after line 5
  4. just after line 6 (that is, as the method returns)
  5. when the calling method sets the argument it passed into this method to null

4. Which is a valid identifier?
  1. false
  2. default
  3. _object
  4. a-class

5. Which two are equivalent? (Choose two.)
  1. 12>4
  2. 12/4
  3. 12*4
  4. 12>>2
  5. 12/2^2
  6. 12>>>1

6. Which two demonstrate a "has a" relationship? (Choose two.)
    • public interface Person{ }
      public class Employee extends Person{ }
    • public interface Shape{ }
      public interface Rectangle extends Shape{ }
    • public interface Colorable{ }
      public class Shape implements Colorable{ }
    • public class Species{ }
      public class Animal{private Species species;}
    • interface Component{ }
      class Container implements Component{
         private Component[] children;
      }

7. Given

double pi = Math.PI;
Which two are valid ways to round pi to an int?(Choose two.)

    • int p = pi;
    • int p = Math.round(pi);
    • int p = (int)Math.round(pi);
    • int p = (int)Math.min(pi + 0.5d);
  1. int p = (int)Math.floor(pi + 0.5d);

8. Which two statements are true for the class java.util.TreeSet? (Choose two.)
  1. The elements in the collection are ordered.
  2. The collection is guaranteed to be immutable.
  3. The elements in the collection are guaranteed to be unique.
  4. The elements in the collection are accessed using a unique key.
  5. The elements in the collection are guaranteed to be synchronized

Return to the top


SUN CERTIFIED PROGRAMMER FOR THE JAVA PLATFORM, JDK 1.1

Note: The certification exam for the jdk 1.1 will be retired January 31, 2001. If you plan to pursue this certification you will need to register by this date. As of February 1, 2001, Sun will only offer certification exams for the Java 2 Platform.

The following samples will help you understand the types of questions you can expect to see when taking the Certified Programmer for the Java Platform, JDK 1.1 examination: Prometric exam number 310-022 (number 310-023 for IBM candidates).
1. Which code fragments would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?
  1. int count = args.length;
  2. int count = args.length - 1;
  3. int count = 0; while (args[count] != null) count ++;
  4. int count=0; while (!(args[count].equals(""))) count ++;

2. Which are keywords in Java (select all that apply)?
  1. sizeof
  2. abstract
  3. native
  4. NULL
  5. BOOLEAN

3. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java on a system with a case-significant file system. Select all that apply.
  1. public class Fred {
            public int x = 0;
            public Fred (int x) {
              this.x = x;
              }
            } 
  2. public class fred 
             public int x = 0;
             public fred (int x) {
               this.x = x;
              }
             }
  3. public class Fred extends MyBaseClass, MyOtherBaseClass {
             public int x = 0;
             public Fred (int xval) {
             x = xval;
            }
           }
  4. protected class Fred {
             private int x = 0;
             private Fred (int xval) {
               x = xval;
              }
             }
  5. import java.awt.*;
             public class Fred extends Object {
               int x;
               private Fred (int xval) {
                 x = xval;
                }
              }

4. A class design requires that a particular member variable must beaccessible for direct access by any subclasses of this class, but otherwise not by classes which are not members of the same package. What should be done to achieve this?
  1. The variable should be marked public
  2. The variable should be marked private
  3. The variable should be marked protected
  4. The variable should have no special access modifier
  5. The variable should be marked private and an accessor method provided

5. Which correctly creates an array of five empty Strings (select all that apply)?
  1. String a [ ] = new String [5]; for (int i = 0; i < 5; a[i++] = "");
  2. String a [ ] = {"", "", "", "", ""};
  3. String a [5];
  4. String [ ] a = new String [5]; for (int i = 0; i < 5; a[i++] = null);
  5. String [5] a;

6. Which cannot be added to a Container?
  1. an Applet
  2. a Component
  3. a Container
  4. a Menu
  5. a Panel
SUN CERTIFIED PROGRAMMER FOR THE JAVA 2 PLATFORM
Sun Educational Services provides sample questions as a means for cand idates to understand the types of questions that you can expect when taking the Sun Certified Programmer for the Java™ 2 Platform exa mination: Prometric exam number 310-025.

1. Given:
  1. public class ArrayTest {
  2.   public static void main (String[] args) {
  3.     Object[] ov;
  4.     String[] sa = { "Green", "Blue", "Red" };
  5.     ov = sa;
  6.     System.out.println("Color = " + ov[1]);
  7.   }
  8. }

What is the result?

  1. fails to compile
  2. prints Color=Blue
  3. prints Color=Green
  4. generates an exception at runtime

2. Given:
    • public class OuterClass {
    •   private double d1 = 1.0;
    •     //insert code here
    • }

You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?(Choose two.)

    • class InnerOne{
        public static double methoda() {return d1;}
      }
    • public class InnerOne{
        static double methoda() {return d1;}
      }
    • private class InnerOne{
        double methoda() {return d1;}
      }
    • static class InnerOne{
        protected double methoda() {return d1;}
      }
  1. abstract class InnerOne{
      public abstract double methoda();
    }

3. Given:
    • public class X {
    •   public void m(Object x) {
    •     x = new Integer(99);
    •     Integer y = (Integer)x;
    •     y = null;
    •     System.out.println("x is" + x);
    •   }
    • }

When is the Integer object, created in line 3, eligible for garbage collection?

  1. never
  2. just after line 4
  3. just after line 5
  4. just after line 6 (that is, as the method returns)
  5. when the calling method sets the argument it passed into this method to null

4. Which is a valid identifier?
  1. false
  2. default
  3. _object
  4. a-class

5. Which two are equivalent? (Choose two.)
  1. 12>4
  2. 12/4
  3. 12*4
  4. 12>>2
  5. 12/2^2
  6. 12>>>1

6. Which two demonstrate a "has a" relationship? (Choose two.)
    • public interface Person{ }
      public class Employee extends Person{ }
    • public interface Shape{ }
      public interface Rectangle extends Shape{ }
    • public interface Colorable{ }
      public class Shape implements Colorable{ }
    • public class Species{ }
      public class Animal{private Species species;}
    • interface Component{ }
      class Container implements Component{
        private Component[] children;
      }

7. Given

double pi = Math.PI;
Which two are valid ways to round pi to an int?(Choose two.)

    • int p = pi;
    • int p = Math.round(pi);
    • int p = (int)Math.round(pi);
    • int p = (int)Math.min(pi + 0.5d);
  1. int p = (int)Math.floor(pi + 0.5d);

8. Which two statements are true for the class java.util.TreeSet? (Choo se two.)
  1. The elements in the collection are ordered.
  2. The collection is guaranteed to be immutable.
  3. The elements in the collection are guaranteed to be unique.
  4. The elements in the collection are accessed using a unique key.
  5. The elements in the collection are guaranteed to be synchronized

Return to the top


SUN CERTIFIED PROGRAMMER FOR THE JAVA PLATFORM, JDK 1.1
Note: The certification exam for the jdk 1.1 will be retired January 31, 2001. If you plan to pursue this certification you will need to register by this date. As of February 1, 2001, Sun will only offer certification exams for the Java 2 Platform.
The following samples will help you understand the types of questions you can expect to see when taking the Certified Programmer for the Java Platform, JDK 1.1 examination: Prometric exam number 310-022 (number 310-023 for IBM candidates).
1. Which code fragments would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?
  1. int count = args.length;
  2. int count = args.length - 1;
  3. int count = 0; while (args[count] != null) count ++;
  4. int count=0; while (!(args[count].equals(""))) count ++;

2. Which are keywords in Solaris (select all that apply)?
  1. sizeof
  2. abstract
  3. native
  4. NULL
  5. BOOLEAN

3. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java on a system with a case-significant file system. Select all that apply.
  1. public class Fred {
            public int x = 0;
            public Fred (int x) {
              this.x = x;
              }
            } 
  2. public class fred 
             public int x = 0;
             public fred (int x) {
               this.x = x;
              }
             }
  3. public class Fred extends MyBaseClass, MyOtherBaseClass {
             public int x = 0;
             public Fred (int xval) {
             x = xval;
            }
           }
  4. protected class Fred {
             private int x = 0;
             private Fred (int xval) {
               x = xval;
              }
             }
  5. import java.awt.*;
             public class Fred extends Object {
               int x;
               private Fred (int xval) {
                 x = xval;
                }
              }

4. A class design requires that a particular member variable must beaccessible for direct access by any subclasses of this class, but otherwise not by classes which are not members of the same package. What should be done to achieve this?
  1. The variable should be marked public
  2. The variable should be marked private
  3. The variable should be marked protected
  4. The variable should have no special access modifier
  5. The variable should be marked private and an accessor method provided

5. Which correctly creates an array of five empty Strings (select all that apply)?
  1. String a [ ] = new String [5]; for (int i = 0; i < 5; a[i++] = "");
  2. String a [ ] = {"", "", "", "", ""};
  3. String a [5];
  4. String [ ] a = new String [5]; for (int i = 0; i < 5; a[i++] = null);
  5. String [5] a;

6. Which cannot be added to a Container?
  1. an Applet
  2. a Component
  3. a Container
  4. a Menu
  5. a Panel
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一些可能会在 Spring Cloud Alibaba 面试被问到的问题及其答案: 1. 什么是 Spring Cloud Alibaba? 答:Spring Cloud Alibaba 是一个基于 Spring Cloud 的开源框架,它提供了在微服务体系结构下构建分布式应用程序所需的一系列解决方案。 2. Spring Cloud Alibaba 与 Spring Cloud 有什么区别? 答:Spring Cloud Alibaba 和 Spring Cloud 在概念和目标上非常相似,但是 Spring Cloud Alibaba 专注于与 Alibaba 生态系统集成,例如阿里云、RocketMQ、Dubbo、Nacos 等等。 3. 什么是 Nacos? 答:Nacos 是一个用于动态服务发现、配置管理和服务管理的平台。它提供了许多特性,例如 DNS 和 HTTP 服务发现、动态配置、流量管理、服务路由、健康检查、服务熔断、灰度发布等等。 4. 什么是 Sentinel? 答:Sentinel 是一个用于流量控制、熔断和系统自适应保护的框架。它可以帮助开发人员解决各种问题,例如服务雪崩、过载保护、慢请求等等。 5. 什么是 Dubbo? 答:Dubbo 是一个高性能、轻量级的 RPC 框架,它提供了服务注册、发现以及远程调用等功能。Dubbo 也是 Alibaba 开源的项目之一。 6. 什么是 RocketMQ? 答:RocketMQ 是一个分布式消息间件,它可以解决大规模分布式系统的消息通信问题。RocketMQ 适用于异步消息处理、高并发、高可用和高吞吐量的场景。 7. 什么是 Seata? 答:Seata 是一个开源的分布式事务解决方案,它可以解决分布式事务的一致性问题。Seata 支持多种事务模式,例如 AT、TCC、SAGA 等等。 以上是一些可能会在 Spring Cloud Alibaba 面试被问到的问题及其答案,希望对您有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值