题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-24 19:11:52

[单选题]阅读下列程序 public class VariableUse{ public static void main (String[] args) { int a; if (a==8) { int b=9; System.out.println("a = "+a); System.out.println("b = "+b); } System.out.println("a = "+a); System.out.println("b = "+b); } } 该程序在编译时的结果是:
A.变量a未赋值
B.第二个System.out.println(“b = ”+b)语句中,变量b作用域有错
C.第二个System.out.println(“a = ”+a)语句中,变量a作用域有错
D.第一个System.out.println(“b = ”+b)语句中,变量b作用域有错

更多"[单选题]阅读下列程序 public class VariableUs"的相关试题:

[单选题]阅读下列程序 public class Test implements Runnable{   private int x=0;   private int y=o;   boolean flag=true;   public static void main(string[ ] args) {     Test r =new Test( );     Thead t1=new Thead(r);     Thead t2=new Thead(r);     t1.start( );     t2.start( );   }   public void run(){     while(flag) {       x++;       y++;       System.out.println("(" +x_ ","+y+")");       if (x>=10)         flag=false;     }   } } 下列对程序运行结果描述的选项中,正确的是:
A.每行的(x,y)中,可能有;每一对(x,y)值都出现两次。
B.每行的(x,y)中,可能有;每一对(x,y)值仅出现一次。
C.每行的(x,y)中,可能有x=y;每一对(x,y)值都出现两次。
D.每行的(x,y)中,可能有x=y;每一对(x,y)值都出现一次。
[单选题]阅读下列利用递归来求n!的程序: class FactorialTest{ static long Factorial (int n) { //定义Factorial ()方法 if (n==1) return 1; else return n* Factorial(_____); } public static void main (String a[]) { // main ()方法 int n=8; System.out.println{n+"! = "+Factorial (n)}; } } 为保证程序正确运行,在下划线处应该填入的参数是:
A.n-1
B.n-2
C.n
D.n+1
[单选题]第125题 (1.0分)
有如下程序.
Const st$="CHINA"
St$="GREAT"
运行后输出的结果是().
A.CHINA
B.GREAT
C.Hebei
D.显示出错信息
[单选题]有如下程序:
Const st$="CHINA"
St$="GREAT"
运行后输出的结果是().
A.CHINA
B.GREAT
C.Hebei
D.显示出错信息
[单选题] 设有如下程序
Public class test {
Public static void main(String args[]) {
Integer intObj=Integer.valueOf(args[args.length-1]);
Int i = intObj.intValue();
If(args.length > 1)
System.out.println(i);
If(args.length > 0)
System.out.println(i - 1);
Else
System.out.println(i - 2);
}
}
运行程序 , 输入如下命令:
Java test 2
则输出为:
A. test
B. test -1
C. 0
D. 1
E. 2
[单选题]阅读下列程序,则在执行后,程序的运行结果为( )。
#include "
#include
Using namespace std;
Int main()
{ char a[30]="nice to meet you!";
strcpy(a+strlen(a)/2,"you");
cout << a;
return 0;
}
A. nice to meet you you
B. nice to
C. meet you you
D. nice to you
[单选题]阅读如下程序段,则程序在先后输入love和china后,输出结果是( )。
Int main()
{ char a[30],b[30];
int k;
gets(a);
gets(b);
k=strcmp(a,b);
if(k>0) puts(a);
else if(k<0) puts(b);
return 0;
}
A. love
B. china
C. lovechina
D. 没有输出结果
[单选题]下列程序的输出结果是: public class Test{   public static void main(String[] args){     int [] array={2,4,6,8,10};     int size=6;     int result=-1;     try{       for(int i=0;iA.Catch---1
B.Catch---2
C.Catch---3
D.以上都不对
[单选题] 下列程序运行的结果为:
Public class test {
Public static void main(String args[]) {
Int i;
Float f = 2.3f ;
Double d = 2.7;
I = ((int)Math.ceil(f)) * ((int)Math.round(d));
System.out.println(i);
}
}
A. 4
B. 5
C. 6
D. 6.1
E. 9
[单选题]有以下程序段 struct st {int x;int *y;}*pt; int a[]={1,2},b[]={3,4}; struct st c[2]={10,a,20,b}; pt=c; 以下选项中表达式的值为11的是()。
A.*pt->y
B.pt->x
C.++pt->x
D.(pt++)->x
[单选题]下列程序的运行结果是: public class test{   private String[] data={"10","10.5"};   public void fun(){     double s=0;     for(int i=0;i<3;i++){       try{         s=s+Integer .parseInt(data[i]);       }catch(Exception e{         System.out.print("errorl:"+data[i]);       }     }   }   public static void main(String[]args){     try{       test d=new test();       d .fun();     }catch(Exception e){       System.out.println("error2");     }   } }
A.errorl:10.5
B.error2
C.errorl:10.5 error2
D.以上都不对
[单选题]以下程序的调试结果为?
Public class Outer{
Public String name = "Outer";
Public static void main(String argv[]){
Inner i = new Inner();
I.showName();
}
Private class Inner{
String name =new String("Inner");
Void showName(){
System.out.println(name);
}
}
}
A.输出结果 Outer
B.输出结果 Inner
C.编译错误,因 Inner 类定义为私有访问
D.在创建 Inner 类实例的行出现编译错误
[单选题]阅读下列代码段 class Test implements Runnable { public int run( ) { int i = 0; while (true) { i++; System.out.println ("i="+i); } } } 上述代码的编译结果是:
A.程序通过编译并且run ()方法可以正常输出递增的i值
B.程序通过编译,调用run ()方法将不显示任何输出
C.程序不能通过编译,因为while的循环控制条件不能为“true”
D.程序不能通过编译,因为run ()方法的返回值类型不是void
[单选题] 以下程序的调试结果为?
class Base{
public final void amethod(){
System.out.println("amethod");
}
}
public class Fin extends Base{
public static void main(String argv[]){
Base b = new Base();
b .amethod();
}
}
A.编译指示带有 final 方法的类自己必须定义为 final
B.编译指示不能继承含有 final 方法的类
C.运行错误,原因是 Base 类没有定义为 final 类
D.运行输出 amethod
[单选题]阅读下面程序,则程序段的功能是( )。
Int main()
{ int c[]={23,1,56,234,7,0,34},i,j,t;
for(i=1;i<7;i++)
{ t=c[i]; j=i-1;
while(j>=0 && t>c[j])
{ c[j+1]=c[j]; j--; }
c[j+1]=t;
}
for(i=0;i<7;i++)
cout << c[i] ;
cout << endl;
}
A. 对数组元素的升序排列
B. 对数组元素的降序排列
C. 对数组元素的倒序排列
D. 对数组元素的随机排列
[单选题] 下列程序运行的结果为:
Public class Example{
String str=new String("good");
Char[] ch={'a','b','c'};
Public static void main(String args[]){
Example ex=new Example();
Ex.change(ex.str,ex.ch);
System.out.print(ex.str+" and ");
Sytem.out.print(ex.ch);
}
Public void change(String str,char ch[]){
Str="test ok";
Ch[0]='g';
}
}
A. good and abc
B. good and gbc
C. test ok and abc
D. test ok and gbc
[单选题]以下程序的编译和运行结果为?
Abstract class Base{
Abstract public void myfunc();
Public void another(){
System.out.println("Another method");
}
}
public class Abs extends Base{
public static void main(String argv[]){
Abs a = new Abs();
a .amethod();
}
public void myfunc(){
System.out.println("My Func");
}
public void amethod(){
myfunc();
}
}
A.输出结果为 My Func
B.编译指示 Base 类中无抽象方法
C.编译通过,但运行时指示 Base 类中无抽象方法
D.编译指示 Base 类中的 myfunc 方法无方法体,没谁会喜欢该方法。
[单选题]阅读下列代码 public class Person{ static int arr[ ] = new int[10]; public static void main (String[] args) { System.out.println(arr[9]); } } 该代码运行的结果是:
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出0
D.输出空

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码