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();}
}
输出结果为: