题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-02-08 07:08:33

[单选题] 以下程序的调试结果为?
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

更多"[单选题] 以下程序的调试结果为? class Base{ publ"的相关试题:

[单选题] 以下程序调试结果为:
Public class Test {
Int m=5;
Public void some(int x) {
M=x;
}
Public static void main(String args []) {
New Demo().some(7);
}
}
Class Demo extends Test {
Int m=8;
Public void some(int x) {
Super.some(x);
System.out.println(m);
}
}
A.5
B. 8
C. 7
D.无任何输出
E.编译错误
[单选题]以下程序的调试结果为?
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 类实例的行出现编译错误
[单选题] 设有如下程序
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
[单选题]已知: class A { public final void m() { System.out.println(“A.m”); } } public class B extends A { public void m() { System.out.println(“B.m”); super.m(); } public static void main(String [] args) { new B().m(); } } 那么结果为?
A.A.m
B.B.m
C.B.m A.m
D.编译错误
[单选题]以下程序调试结果为:
Class Base{
Base(){
Int i = 100;
System.out.print (i);
}
}
Public class Pri extends Base{
Static int i = 200;
Public static void main(String argv[]){
Pri p = new Pri();
System.out.print(i);
}
}
A.编译错误
B.200
C. 100200
D. 100
[多选题]设有如下代码:
Class Base{}
Public class MyCast extends Base{
Static boolean b1=false;
Static int i = -1;
Static double d = 10.1;
Public static void main(String argv[]){
MyCast m = new MyCast();
Base b = new Base();
//Here
}
}
则在 //Here 处插入哪个代码将不出现编译和运行错误。
A. b=m;
B. m=b;
C. d =i;
D. b1 =i;
[单选题]已知: class Base { public Base(String s) { System.out.print(“B”); } } public class Derived extends Base { public Derived (String s) { System.out.print(“D”); } public static void main(String [] args) { new Derived (“C”); } } 那么结果为?
A.BD
B.DB
C.C
D.编译错误
[单选题]编译并运行以下程序段的结果是:( )
Public class MyClass{
Final static int i;
MyClass(){i =0;}
Public static void main(String args[]){
System.out.println(i);
}
}
A.编译出错
B.null
C.1
D.0
[单选题] 在Java中,以下程序编译运行后的输出结果为( )。
Public class Test {
Int x, y;
Test(int x, int y) {
This.x = x;
This.y = y;
}
Public static void main(String[] args) {
Test pt1, pt2;
Pt1 = new Test(3, 3);
Pt2 = new Test(4, 4);
System.out.print(pt1.x + pt2.x);
}
}
A. 6
B. 3 4
C. 8
D. 7
[单选题]阅读下列程序 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 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
[单选题]阅读下列程序 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)值都出现一次。
[单选题] 设有类定义如下:
Class Base{
Public Base(int i){}
}
Public class MyOver extends Base{
Public static void main(String arg[]){
MyOver m = new MyOver(10);
}
MyOver(int i){
Super(i);
}
MyOver(String s, int i){
This(i);
//Here
}
}
以下哪条语句可以安排在 //Here 处 ?
A. MyOver m = new MyOver();
B. super();
C. this("Hello",10);
D. Base b = new Base(10);
[单选题]下列程序的运行结果是: 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.以上都不对
[单选题]下面代码执行结果为() class A { public: void B() { cout<<"want func ptr"; } }; int main() { void (A::*func)() = &A::B; A a; (a.*func)(); return 0; }
A.want func ptr
B.编译错误,A类中没有成员*func函数
C.没有任何输出
D.不能A::B取地址
[单选题] 下列程序运行的结果为:
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
[单选题]试完成下述程序片段:
Public class Point()
{ int x,y;
Public Point(int x,int y)
{ =x; =y;
}
......
}
A. Point.x Point.y
B.无解
C. x1 y1
D. this.x this.y
[单选题]对下列程序的叙述中,正确的是:   1:public class X extends Thread implements Runnable{   2:  public void run(){   3:    System.out.println("this is run()");   4:  }   5:  public static void main(String args[]){   6:    Thread t=new Thread(new X());   7:    t.start();   8:  }   9:}
A.第1行会产生编译错误
B.第6行会产生编译错误
C.第6行会产生运行错误
D.程序正常运行

我来回答:

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

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码