在线考试(1)
来源:互联网 发布:优生优育重要性知乎 编辑:程序博客网 时间:2024/04/30 18:49
以下程序的输出结果正确的是。
public class test {
public static void main(String args[]) {
int x=1,y=1,z=1;
if(x--==1&&y++==1||z++==1)
System.out.println("x="+x+",y="+y+",z="+z);
}
}请问以下API哪个可以在构建对象时指定编码方式呢()
java.io.InputStream
java.io.OutputStream
java.io.InputStreamReader
下列代码的输出结果是()。
int j=0;
for(int i=0;i<100;i++){
j=j++;
}
System.out.println(j);
下列不属于Java运算符的是()。
!=
<>
>>
<<
请看下列代码的输出结果是:
public class Bootchy {
int bootch;
String snootch;
public Bootchy() {
this("snootchy");
System.out.print("first ");
}
public Bootchy(String snootch) {
this(420, "snootchy");
System.out.print("second ");
}
public Bootchy(int bootch, String snootch) {
this.bootch = bootch;
this.snootch = snootch;
System.out.print("third ");
}
public static void main(String[] args) {
Bootchy b = new Bootchy();
System.out.print(b.snootch + " " + b.bootch);
}
}
first second third snootchy 420
third second first snootchy 420
third first second snootchy 420
下列属性中专属于RelativeLayout布局的是()。
android:layout_weight
android:layout_below
android:stretchColumns
android:layout_x
分析如下代码,输出结果为()。
public static void main(String[] args) {
int i = 0;
boolean re = false;
re = ((++i) + i == 2) ? true : false;
System.out.println("i=" + i + ",re="+re);
}
i=1,re=true
i=0,re=true
i=1,re=false
下列代码编译和运行的结果是:
public class A {
void process() throws Exception {
throw new Exception();
}
public static void main(String[] args) {
A a = new B();
a.process();
}
}
class B extends A {
void process() {
System.out.println("B ");
}
}
输出:B
无输出
B类的process方法处,出现编译错误
阅读以下程序选择正确答案:()
public class foo {
public static void main (String[]args){
Integer t1=127,t3=128;
Integer t2=127,t4=128;
System.out.println(t1==t2);
System.out.println(t1.equals(t2));
System.out.println(t3==t4);
System.out.println(t3.equals(t4));
}
}
请问下列代码的执行结果是:
class Base{
void Test( ){
System.out.println(“Base.test()”);
}
}
public class Child extends Base{
void test(){
System.out.println(“Child.test()”);
}
public static void main(String[] a){
Child child=new Child();
Base base=new child();
Base.test();
}
}
Child.test() Base.test()
Base.test() Child.test()
Base.test()
有变量声明如下:
short b = 120;
下列语句中,错误的是()。
short s = b;
int i = b;
byte s1 = b;
程序执行的结果是()。
public class Test {
String name="Tom";
public Test(String name){
name=name;
}
public static void main(String [] args){
Test t = new Test("Jack");
System.out.println(t.name);
}
}
Null
Tom
Jack
在<插入代码>处,填入下列代码编译正确的是:
public void foo(int[] x) {
<插入代码>
}
foreach(int z : x) System.out.println(z);
for(int z : x) System.out.println(z);
while( x.hasNext()) System.out.println( x.next());
for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
下列方法中不属于TimePicker控件的方法是()。
voidsetCurrentHour(int hour)
voidsetCurrentMinute(int minute)
setOnTimeSetListener(OnTimeSetListener listener)
setOnTimeChangedListener(OnTimeChangedListener listener)
阅读以下程序输出正确答案:()
public class foo {
public static void main (String[]args){
List<Integer> lst=new ArrayList<Integer>();
lst.add(1);
lst.add(new Integer(2));
lst.add(1,3)
System.out.println(lst)
}
}
选择布局代码的正确展现形式
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_weight="1"
android:background="#fff453"
android:text="A"
android:textColor="#000000"
android:gravity="center"
android:textSize="35dp"
android:layout_height="fill_parent"
/>
<TextView
android:text="B"
android:textColor="#000000"
android:gravity="center"
android:textSize="35dp"
android:layout_width="fill_parent"
android:layout_weight="1"
android:background="#f22453"
android:layout_height="fill_parent"
/>
</LinearLayout>
阅读以下程序输出正确答案:()
public class Test {
public static void main (String[]args){
Set<Integer> lst=new HashSet<Integer>();
lst.add(1);
lst.add(new Integer(2));
lst.add(1,3)
System.out.println(lst)
}
}
阅读以下程序选择说法正确的选项()
public class Test {
public static void main (String args[]) {
class Foo {
public int i = 3;
}
Object o = (Object) new Foo();
Foo foo = (Foo)o;
System.out.println(foo. i);
}
}程序的执行结果是:
public class Test {
public static void main(String [] args){
System.out.println(“”+'a'+1);
}
}
98
a1
971
以下程序正确的输出结果为:()
class StringDemo{
public static void main(String []args){
String m1=”HelloWorld”;
String m2=new String(“HelloWorld”);
System.out.println(m1==m2);
System.out.println(m1.equals(m2));
String m3=new String(“HelloWorld”);
System.out.println(m2==m3);
}
}关于以下程序代码的说明,正确的一项是()
Line 1:class HashSTaticTest{
Line 2:private static int x=10;
Line 3:pulic static void main(String args[]){
Line 4:HashStaticTest hs1=new HashStaticTest();
Line 5:hs1.x++;
Line 6:HashStaticTest hs2=new HashStaticTest();
Line 7:hs2.x++;
Line 8:hs1=new HashStaticTest();
Line 9:hs1.x++;
Line 10:HashStaticTest.x--;
Line 11:System.out.println(“x=”+x);
Line 12: }
Line 13:}
5行不能通过编译,因为引用了私有静态变量
10行不能通过编译,因为x 是私有静态变量
程序通过编译,输出结果:x=13
请看下列代码
public class Foo {
public void method(String str,int age){}
}
和Foo类中method方法重载的方法是:
public int method(String str,int age){}
public void method(String s,int year){}
public void method(int year,String s){}
关于CheckedTextView,下列说法正确的是()
当android:checkMark属性的值为?android:attr/listChoiceIndicatorSingle时选择模式为单选
当android:checkMark属性的值为singleChoiceIndicatorMultiple时选择模式为多选
当android:checkMark属性的值为singleChoiceIndicator时选择模式为单选
当android:checkMark属性的值为?android:attr/MultipleChoiceIndicator时选择模式为单选
下列代码的运行结果是:
public class GoTest {
public static void main(String[] args) {
Sente a = new Sente();
a.go();
Goban b = new Goban();
b.go();
Stone c = new Stone();
c.go();
}
}
class Sente implements Go {
public void go() {
System.out.println("go in Sente");
}
}
class Goban extends Sente {
public void go() {
System.out.println("go in Goban");
}
}
class Stone extends Goban implements Go {
}
interface Go {
public void go();
}
go in Goban
go in Sente
go in Sente
go in Sente
go in Sente
go in Goban
go in Sente
go in Goban
go in Goban
go in Goban
go in Goban
go in Sente
请看下列代码编译和运行的结果是()。
interface DeclareStuff {
public static final int EASY = 3;
void doStuff(int t);
}
public class TestDeclare implements DeclareStuff {
public static void main(String[] args) {
int x = 5;
new TestDeclare().doStuff(++x);
}
void doStuff(int s) {
s += EASY + ++s;
System.out.println("s=" + s);
}
}
s=14
s=16
s=10
下列代码的输出结果是()。
public static void main(String[] args) {
int[] one=new int[]{4,6,8};
int[] two=new int[]{1,3,5,7,9};
System.arraycopy(one, 1, two, 2, 2);
System.out.println(Arrays.toString(two));
}
[1, 3, 7, 4, 6]
[1, 3, 5, 7, 8]
[1, 3, 5, 6, 9]
关于下列代码说法正确的是:
class ClassA {
public int numberOfinstances;
protected ClassA(int numberOfinstances) {
this.numberOfinstances = numberOfinstances;
}
}
public class ExtendedA extends ClassA {
private ExtendedA(int numberOfinstances) {
super(numberOfinstances);
}
public static void main(String[] args) {
ExtendedA ext = new ExtendedA(420);
System.out.print(ext.numberOfinstances);
}
}
运行后,输出420
运行时抛出异常
编译错误,所有的构造器必须是public的
下列属性中专属于LinearLayout的是()。
android:layout_width
android:layout_height
android:layout_gravity
android:layout_weight
执行下列语句:
int num=~3+2; 变量num的值为()。
在下面的程序中,/*插入代码*/处可以插入哪些关键字()
public interface Status{
public interface Status{
/*插入代码*/ int MY_VALUE=100;
}
}
final
static
public
下列与数组有关的javaScript语句中,语法错误的是()
var arr-new Array(10);
var an=new Array[10];
var arr1=[1,2,3]; var arr2=[‘TARENA’,arr1,[10,20]];
var arr=[10,20,30]; for (int i=1;i<=arr.length;i++){ alert(arr[i]); }
与下面函数构成重载关系的选项为:()
public class GlobalTest{
public GlobalTest(int x,int y){
}
}
GlobalTest(){ }
protected int GlobalTest(){ }
private GlobalTest(int z,int y,int x){ }
以下程序中可以插入哪些的关键字:()
public interface Status {
/* 插入代码 */ int MY_VALUE = 10;
}阅读如下代码(使用Gallery显示指定目录下的图片,支持手势操作),并完成下面 5 题。
Public class ImageInfo{
Private String title;
Private Bitmap bitmap;
//略去getter和setter
…
}
public class ImageBiz{
//查询指定目录下的所有图片信息
Public ArrayList<ImageInfo> getThumbs(){
//略去加载指定目录图片的代码
…
}
}
public class ImageAdapter extends BaseAdapter{
//略去具体实现代码
}
public class MainClass extends Activity{
private Gallery galThumbs;
private ImageBiz biz;
private ImageAdapter adapter;
private GestureDetector detector;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
biz = new ImageBiz();
setupView();
addListener();
detector = new GestureDetector(new MyGestureListener());
}
private void setupView(){
galThumbs = (Gallery)findViewById(R.id.galThumbs);
adapter = new ImageAdapter(this,biz.getThumbs());
galThumbs.setAdapter(adapter);
}
private void addListener(){
galThumbs.setOnItemSelectedListener(
newOnItemSelectedListener(){
public void onItemSelected(AdapterView<?> gal, View item,
int position, long id) {
ImageInfo thumb = (ImageInfo)adapter.getItem(position);
String path = "/mnt/sdcard/imgs/"+thumb.getTitle();
ivPicShow.setImageBitmap(getBitmap(path,80,120));
}
Public void onNothingSelected(AdapterView<?> arg0) {}
});
}
public void onTouchEvent(MotionEvent event){
_____空白处5__________
returnsuper.onTouchEvent(event);
}
/**
*按指定大小加载并收缩图片
*/
private Bitmap getBitmap(String path,intwidth,int height){
Bitmap bm = null;
if(path!=null){
Options opts = newOptions();
//加载程序边界信息
____空白处1_________
intxScale = opts.outWidth / width;
intyScale = opts.outHeight / height;
opts.inSampleSize = xScale>yScale?xScale:yScale;
//收缩并加载图片
_____空白处2__________
}
Return bm;
}
Private classMyGestureListener extends SimpleOnGestureListener{
Public Boolean onFling(MotionEvent e1, MotionEvent e2, floatvelocityX,
floatvelocityY) {
int currentPosition = galThumbs.getSelectedItemPosition();
if(e1.getX()-e2.getX()>20 &&Math.abs(velocityX)>100){
//从右向左滑屏,显示下一张图片,如果右越界显示第一张
______空白处3_____
}else if(e2.getX()-e1.getX()>20 &&Math.abs(velocityX)>100){
//从左向右滑屏
______空白处4_____ }
Return super.onFling(e1, e2, velocityX, velocityY);
}
}
}
下列选项中,能填入空白处1的代码是( )
opts.inJustDecodeBounds=true;
BitmapFactory.getBitmap(path,opts);
opts.inJustDecodeBounds=true;
BitmapFactory.decodeFile(path,opts);
BitmapFactory.getBitmap(path,opts);
BitmapFactory.decodeFile(path,opts);
下列选项中,能填入空白处2的代码是( )
opts.inJustDecodeBounds=false;
BitmapFactory.getBitmap(path,opts);
opts.inJustDecodeBounds=false;
BitmapFactory.decodeFile(path,opts);
bm = BitmapFactory.getBitmap(path,opts);
opts.inJustDecodeBounds=false;
bm = BitmapFactory.decodeFile(path,opts);
下列选项中,能填入空白处3的代码是( )
if(++currentPosition==galThums.getChildCount()){
currentPosition = 0;
}
if(++currentPosition==galThumbs.getCount()-1){
currentPosition = 0;
}
if(++currentPosition==adapter.getCount()){
currentPosition = 0;
}
if(++currentPosition==galThums.getChildCount()-1){
currentPosition = 0;
}
下列选项中,能填入空白处4的代码是( )
if(--currentPosition<0){
currentPosition = galThums.getChildCount();
}
if(--currentPosition<0){
currentPosition = galThums.getChildCount()-1;
}
if(--currentPosition<0){
currentPosition = galThums.getCount()-1;
}
if(--currentPosition<0){
currentPosition = adapter.getCount();
}
下列选项中,能填入空白处5的代码是( )
detector.onTouch(event);
detector.addOnTouchEvent(event);
detector.onTouchEvent(event);
detector.setOnTouchEvent(event);
阅读如下代码,并完成下面5题。
class ClassA{
public ClassA(){
System.out.println("ClassA()");
}
}
class ClassB{
public ClassB(){
System.out.println("ClassB()");
}
}
class ClassC{
ClassA a = new ClassA();
ClassB b;
public ClassC(){
System.out.println("ClassC()");
b = new ClassB();
}
}
public class TestConstructor{
public static void main(String args[]){
ClassC cc = new ClassC();
}
}编译有问题,可以将ClassC中成员变量b的定义,修改为ClassA.ClassB b,同时
将ClassC的构造函数中b对象的构建改为b=new ClassA().ClassB()冒泡排序原理:
a 逐一比较数组中相邻的两个元素, 如果后面的数字小于前面的数字, 就交换先后元素.
b 经过一个轮次的比较, 一定有一个最大的排在最后的位置.
c 每次比较剩下的元素, 最多经过n-1次比较, 可以实现排序
简单说: 比较相邻元素,大的向后交换。
public static void main(String args[]) {
空白处1 (定义一个整型数组并初始化,要求数据位1,7,6,2,5,4,3)
for (int j = 0; 空白处3 ; j++) {//控制比较每轮比较的次数
if ( 空白处4 ) {
int t = ary[j];
空白处5
ary[j + 1] = t;
}
System.out.println();
}
}
}
- 在线考试(1)
- 在线考试系统(1)
- 在线考试
- 教学设计在线考试
- 在线考试系统
- 在线考试脚本
- NIIT在线考试
- javasprint 在线考试计时器
- c在线考试系统
- 远程教育在线考试系统
- 在线网络考试系统
- 在线考试(2)
- 在线考试(3)
- testlink_在线考试系统
- PMP在线考试
- 在线考试总结
- 在线考试系统源码
- 在线考试系统
- Special Offer! Super Price 999 Bourles!
- linux下面的xdebug安装
- Web知识日记
- 关于PageContext
- JAVA常用类之——String和String Builler
- 在线考试(1)
- JAVA常用类之——BigInteger和BigDecimal
- The network connection was lost 文件下载错误提示
- GRE写作必备句型
- code国际化
- JAVA常用类之——正测表达式
- Codeforces Round #256 (Div. 2)
- noHandlerFound问题
- UI开发中的辅助方法