考试网 >> IT认证 >> JAVA >> JAVA指导 >> Java程序员认证模拟题及详细分析

Java程序员认证模拟题及详细分析

发布时间:2006-06-28 10:51     点击:
分页:上一页  1 2 3 4 5 6 7 8 9 [10]  下一页  后10页

47. Given this skeleton of a class currently under construction:

public class Example{

int x,y,z;

public Example (int a, int b) {

//lots of complex computation

x=a; y=b;

}

public Example(int a, int b, int c){

// do everything the same as single argument

// version of constructor

// including assignment x=a, y=b, z=c

z=c;

}

}

What is the most concise way to code the “do everything…” part of the constructor taking two arguments?

Short answer:

48. Which correctly create a two dimensional array of integers?

A. int a[][] = new int[][];

B. int a[10][10] = new int[][];

C. int a[][] = new int[10][10];

D. int [][]a = new int[10][10];

E. int []a[] = new int[10][10];

49. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java?

A. public class Fred{

public int x = 0;

public Fred (int x){

this.x=x;

}

}

B. public class fred{

public int x = 0;

public Fred (int x){

this.x=x;

}

}

C. public class Fred extends MyBaseClass, MyOtherBaseClass{

public int x = 0;

public Fred(int xval){

x=xval;

}

}

D. protected class Fred{

private int x = 0;

private Fred (int xval){

x=xval;

}

}

E. import java.awt.*;

public class Fred extends Object{

int x;

private Fred(int xval){

x = xval;

}

}

50. A class design requires that a particular member variable must be accessible 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 2 3 4 5 6 7 8 9 [10]  下一页  后10页
版权申明:未经书面授权请勿转载本站信息!!作品版权归所属媒体与作者所有!!
发表评论: 匿名发表 用户名: 查看评论
您将承担一切因您的行为、言论而直接或间接导致的民事或刑事法律责任
留言板管理人员有权保留或删除其管辖留言中的任意内容
本站提醒:不要进行人身攻击。谢谢配合。
在本站搜索相关信息
2003-2005 Ksw123.com All Rights Reserved. - TOP
Copyright © 2006 Ksw123.com. All rights reserved.中国考题网 版权所有