举一反三
- 以下是"public static void test(int x, int y)"的方法重载
- 已有如下程序: public class Test{ public Test(int x,int y,int z){.....} } 下面哪些方法是合法的构造方法重载:( ) A: Test(){} B: int Test(){} C: Test(int x,int y,byte z){} D: void Test(int x,int y,int z){}
- (6-6)请阅读程序,写出程序运行结果。 class Test{ static int x=10; int y=99; { y=y+10; } static { x=x+5; } { y=y+10; } static { x=x+5; } public Test() {//构造方法 x=x+5; } { System.out.println(x*y); } } public class Demo11 { public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(); } }
- 请说出下列程序错在哪里?给出具体原因。 public class Test { public static void method(int x) { } public static int method(int y) { return y; } }
- using System; class Test { public static void Main() { int x = 5; int y = x++; Console.WriteLine(y); y=++x; Console.WriteLine(y); } }
内容
- 0
(1+X)以下哪个不是 “public static void aMethod(){...}” 的重载方法( )? A: public static void aMethod(int num ) ; B: public static int aMethod() ; C: public static void aMethod(int num ,String name) ; D: public static void aMethod(String name) ;
- 1
分析以下C#代码,其运行结果是______ using System;class Test{ public static void Main() { int x = 5; int y = x++; y=++x; Console.Write (y); }}
- 2
给定Java代码如下所示,在横线处新增下列( )方法,是对cal方法的重载。public class Test{ public void cal(int x, int y, int z) { } }
- 3
不能与该方法构成重载的方法是() public double fun(int x,double y){ return x + y; } A: public void fun(int x){ System.out.println("x * x="+(x*x)); } B: public void fun(int a, double b){ System.out.println("a +b ="+(a+b)); } C: public int fun(int x, int y,int z){ renturn (x+y+z); } D: public double fun(double x, int y){ return x * y ; }
- 4
1. 写出以下程序的运行结果。 class Test { public static void Main() { int x = 5; int y = x++; Console.WriteLine(y); y=++x; Console.WriteLine(y); Console.WriteLine(x); } } 运行结果: