栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > Java面试题

Java语言程序设计测试题程序阅读题部分

Java面试题 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java语言程序设计测试题程序阅读题部分

1、阅读以下程序,输出结果为                   。class Q1{ public  static void  main(String   args[  ]){ double  d=1.23; Dec  dec=new  Dec(  ); dec.decrement(d); System.out.println(d); } classs   Dec{ public void  decrement(double   decMe){ decMe = decMe - 0.1;} }2、以下程序的输出结果为                       。 public  class  Short{ public  static  void  main(String  args[ ]) { StringBuffer  s = new  StringBuffer(“Hello”); if((s.length( )>5)&& (s.append(“there”) . equals(“False”))) ; System.out.println(“value  is”+s); } }3、以下程序段的输出结果为                      。 int   x=0,y=4, z=5; if ( x>2){ if (y<5){ System.out.println(“Message  one”); } else { System.out.println(“Message  two”); } } else if(z>5){ System.out.println(“Message  three”); } else { System.out.println(“Message  four”); }4、以下程序段的输出结果为                                       。 int   j=2; switch  ( j ) { case  2: System.out.print(“Value is two.”); case  2+1 : System.out.println(“Value is three.”); break; default: System.out.println(“value is “+j); break; }5、 阅读以下程序段:class  Parent{ void  printMe() { System.out.println(“parent”); }}class  Child  extends Parent{ void  printMe() { System.out.println(“child”); } void  printAll() { super.printMe(); this.printMe(); printMe(); }}public class Test_this{ public static void main(String  args[ ]) { Child  myC=new  Child(); myC.printAll();}}输出结果为:

1、阅读以下程序,输出结果为                   。

class Q1{

public  static void  main(String   args[  ]){

double  d=1.23;

Dec  dec=new  Dec(  );

dec.decrement(d);

System.out.println(d);

}

classs   Dec{

public void  decrement(double   decMe){

decMe = decMe - 0.1;

}

}

2、以下程序的输出结果为                       。

public  class  Short{

public  static  void  main(String  args[ ]) {

StringBuffer  s = new  StringBuffer(“Hello”);

if((s.length( )>5)&& (s.append(“there”) . equals(“False”)))

;

System.out.println(“value  is”+s);

}

}

3、以下程序段的输出结果为                      。

int   x=0,y=4, z=5;

if ( x>2){

if (y<5){

System.out.println(“Message  one”);

}

else {

System.out.println(“Message  two”);

}

}

else if(z>5){

System.out.println(“Message  three”);

}

else {

System.out.println(“Message  four”);

}

4、以下程序段的输出结果为                                       。

int   j=2;

switch  ( j ) {

case  2:

System.out.print(“Value is two.”);

case  2+1 :

System.out.println(“Value is three.”);

break;

default:

System.out.println(“value is “+j);

break;

}

5、 阅读以下程序段:

class  Parent

{

void  printMe()

{

System.out.println(“parent”);

}

}

class  Child  extends Parent

{

void  printMe()

{

System.out.println(“child”);

}

void  printAll()

{

super.printMe();

this.printMe();

printMe();

}

}

public class Test_this

{

public static void main(String  args[ ])

{

Child  myC=new  Child();

myC.printAll();}

}

输出结果为:

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/359516.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号