import java.io.PrintWriter; class DoFormat { public static void main(String [] args) { int x = 42; int y = 12345; float z = 7; System.out.format("-%4d- ", x); System.out.format("-%4d- ", y); System.out.format("-%4.1d- ", z); } } 结果为:() A、编译失败B、-42- -1234- -7.0-C、- 42- -1234- - 7.0-D、运行时异常被抛出
import java.io.PrintWriter; class DoFormat { public static void main(String [] args) { int x = 42; int y = 12345; float z = 7; System.out.format("-%4d- ", x); System.out.format("-%4d- ", y); System.out.format("-%4.1d- ", z); } } 结果为:()
- A、编译失败
- B、-42- -1234- -7.0-
- C、- 42- -1234- - 7.0-
- D、运行时异常被抛出
相关考题:
以下程序的运行结果为( )。 public class Sun { public static void main(String args[]) { String x="A",y="B",z="C"; for(int m=1;m<=2;m++) { x=y; y=z; z=x; } System.out.println(x+y+z); } }A.ABCB.BCAC.BCBD.CBC
阅读下面程序public class Test3{public static void main(String args[]){int x=3,y=4,z=5;String s= " xyz " ;System.out.println(s+x+y+z);}}程序运行的结果是A)xyz12B)xyz345C)xyzxyzD)12xyz
importjava.io.PrintWriter;classDoFormat{publicstaticvoidmain(String[]args){intx=42;inty=12345;floatz=7;System.out.format(-%4d-,x);System.out.format(-%4d-,y);System.out.format(-%4.1d-,z);}}结果为:()A.编译失败B.-42--1234--7.0-C.-42--1234--7.0-D.运行时异常被抛出
现有importjava.io.PrintWriter;classDoFormat{publicstaticvoidmain(String[]args){intx=42;inty=12345;floatZ-7;System.out.format(一%4d-,X);System.out.format(-%4d-,y);System.out.format(-%4.ld-,z);}}结果为:()A.编译失败B.-42--1234--7.0-C.-42--1234--7.0-D.-42--12345--7.0-E.运行时异常被抛出
下面程序段的输出结果为 package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过
执行下列代码段之后,变量z的值为______。 Public class Test8 { public static void main(String[] args) { int x=2; int y=3; int z=4; z-....= y-x--; System.out.println(z); }A.1B.2C.3D.4
阅读下面程序 public class Test3 { public static void main(String[] args) { int x=3,y=4,z=5; String s="xyz": System.out.println(s+x+y+z); } } 程序运行的结果是A.xyz12B.xyz345C.xyzxyzD.12xyz
下面程序段的输出结果为( )。 package test; public class ClassA { int x=20: static int y=6; public static void main(String args[]) { ClassB b=new ClassB; go(10); System.out.println("x="+b.x); } } class ClassB { int X; void go(int y) { ClassA a=new ClassA; x=a.Y ; } }A.x=10B.x=20C.x=6D.编译不通过
下面程序段的输出结果为 package test; public class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println(”x=”+b.x); } } class Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过
下面程序段的输出结果为 package test; public class Class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println("x"+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x-20C.x=6D.编译不通过
以下程序的输出结果为:public class test {public static void main(String args[]) {int x=1,y=1,z=1;if (x--==1}} A. x=0,y=2,z=1B. x=1,y=2,z=1C. x=0,y=1,z=1D. x=0,y=2,z=2
Less Test{ public static void main(String[] args){ for(int x=0;x7;++x){ int y=2; x=++y; } System.out.println(“y=”+y); } } 结果为:() A、y=5B、y=6C、 y=7D、y=8E、编译失败F、运行时异常被抛出
现有 import java.io.PrintWriter; class DoFormat{ public static void main (String [] args) { int x=42; int y=12345; float Z-7 ; System.out.format("一%4d-", X); System. out.format("-%4d-", y); System. out.format("-%4.ld-",z); } } 结果为:() A、编译失败B、 -42- -1234- -7.0-C、 - 42- -1234- -7.0-D、 - 42- -12345- -7.0-E、运行时异常被抛出
class Foo { public static void main(String [] args) { int x = 0; int y = 4; for(int z=0; z 〈 3; z++, x++) { if(x 〉 1 ++y 〈 10) y++; } System.out.println(y); } } 结果是什么?() A、6B、7C、8D、10
现有: class Foo { public static void main (String [] args) { int x=O; int y=4; for (int z=0; z3; Z++; X++) { if(x1++y10) y++; } System. out .println (y); } } 结果是什么?() A、7B、8C、10D、12
现有: class TestMain { static int x = 2; static { x = 4; } public static void main(String... args) { int y = x + 1; System.out.println(y); } } 和命令行: java TestMain 结果为:() A、 3B、 5C、 编译失败D、 运行时异常被抛出
class Top { static int x = 1; public Top(int y) { x *= 3; } } class Middle extends Top { public Middle() { x += 1; } public static void main(String [] args) { Middle m = new Middle(); System.out.println(x); } } 结果为:() A、1B、2C、3D、编译失败
public class MethodOver { private int x, y; private float z; public void setVar(int a, int b, float c){ x = a; y = b; z = c; } } Which two overload the setVar method?()A、 void setVar (int a, int b, float c){ x = a; y = b; z = c; }B、 public void setVar(int a, float c, int b) { setVar(a, b, c); }C、 public void setVar(int a, float c, int b) { this(a, b, c); }D、 public void setVar(int a, float b){ x = a; z = b; }E、 public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }
class TestMain { static int x = 2; static { x = 4; } static public void main(String[] args) { int y = x + 1; System.out.println(y); } } 和命令行: java TestMain 结果为:()A、 3B、 5C、 编译失败D、 运行时异常被抛出
class Test2{ public static void main(String [] args){ boolean x=true; boolean y=false; short z=42; if((x==true)y=true))z++; if((y==true||++z=44))z++; System.out.println(“z=”+z); } } 结果是什么?() A、 z=42B、 z=43C、z=44D、 z=45E、编译失败F、运行的时候有异常抛出
单选题现有: class TestMain { static int x = 2; static { x = 4; } public static void main(String... args) { int y = x + 1; System.out.println(y); } } 和命令行: java TestMain 结果为:()A 3B 5C 编译失败D 运行时异常被抛出
单选题Less Test{ public static void main(String[] args){ for(int x=0;x7;++x){ int y=2; x=++y; } System.out.println(“y=”+y); } } 结果为:()Ay=5By=6C y=7Dy=8E编译失败F运行时异常被抛出
单选题现有: class TestMain { static int x = 2; static { x = 4; } static public void main(String[] args) { int y = x + 1; System.out.println(y); } } 和命令行: java TestMain 结果为:()A 3B 5C 编译失败D 运行时异常被抛出
单选题现有 import java.io.PrintWriter; class DoFormat{ public static void main (String [] args) { int x=42; int y=12345; float Z-7 ; System.out.format("一%4d-", X); System. out.format("-%4d-", y); System. out.format("-%4.ld-",z); } } 结果为:()A编译失败B -42- -1234- -7.0-C - 42- -1234- -7.0-D - 42- -12345- -7.0-E运行时异常被抛出
单选题现有: class Foo { public static void main (String [] args) { int x=O; int y=4; for (int z=0; z1++y10) y++; } System. out .println (y); } } 结果是什么?()A7B8C10D12
单选题import java.io.PrintWriter; class DoFormat { public static void main(String [] args) { int x = 42; int y = 12345; float z = 7; System.out.format("-%4d- ", x); System.out.format("-%4d- ", y); System.out.format("-%4.1d- ", z); } } 结果为:()A编译失败B-42- -1234- -7.0-C- 42- -1234- - 7.0-D运行时异常被抛出
多选题public class MethodOver { private int x, y; private float z; public void setVar(int a, int b, float c){ x = a; y = b; z = c; } } Which two overload the setVar method?()Avoid setVar (int a, int b, float c){ x = a; y = b; z = c; }Bpublic void setVar(int a, float c, int b) { setVar(a, b, c); }Cpublic void setVar(int a, float c, int b) { this(a, b, c); }Dpublic void setVar(int a, float b){ x = a; z = b; }Epublic void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }