网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
以下代码有问题,下列说法正确的是()。代码如下:public A{public void method(){} (1)public string method(){} (2)public string method(int a){} (3)}
A、(1)和(2)删掉一个,错误解决
B、(3)删掉,错误解决
C、没问题
参考答案
更多 “ 以下代码有问题,下列说法正确的是()。代码如下:public A{public void method(){} (1)public string method(){} (2)public string method(int a){} (3)} A、(1)和(2)删掉一个,错误解决B、(3)删掉,错误解决C、没问题 ” 相关考题
考题
阅读下列代码段,选出该代码段的正确文件名( )。 class A { void methodl() { System.out.println("methodl in class A"); } } public class B { void method2() { System.out.println("method2 in class B"); } public static void main(String args[]) { System.out.println("main in class B"); } }A.A.javaB.A.classC.B.classD.B.java
考题
阅读下列代码段,选出该代码段的正确文件名( )。 class A { void method1() { System.out.println("method1 in class A"); } } public class B { void method2() { System.out.println("method2 in class B"); } public static void main(String args[]) { System.out.println("main in class B"); } }A.A.javaB.A.classC.B.classD.B.java
考题
下列代码的执行结果是______。public class Expression{public static void main(String args[]){int v1=10, v2=99, v3=0;System out println((v1<0)((v2/v3)= =3));}}
考题
下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new TeA.0B.1C.2D.3
考题
下列程序中,要求计算1+2+3+…+100的值,并显示计算结果。请将程序补充完整。程序运行结果如下:5050public class ex6_1{public static void main(Stringr)args){ex6_1 obj6_1:new ex6_1();obj6_1.method6_1();}public void method6_1(){int sum;___________;for(int i=1;i<=100;i++){___________;}___________;}}
考题
A programmer needs to create a logging method that can accept an arbitrary number of arguments.Forexample,it may be called in these ways:logIt(log message 1);logIt(log message 2”,”log message 3);logIt(log message 4,log message 5,log message 6);Which declaration satisfies this requirement()?A.public void logIt(String*msgs)B.public void logIt(String[]msgs)C.public void logIt(String...msgs)D.public voidl ogIt(Stringmsg1,Stringmsg2,Stringmsg3)
考题
下列程序中,给出两个整数2和3,分别求2除以3和2乘以3的结果,要求调用类ex19_1的方法method()来输出相应的结果,请将程序补充完整。程序运行结果如下。0.66666666666666666源程序文件代码清单如下:public class exl9 1{public static void main(String args[]){int n1=2,n2=3;ex19_1 obj19_1=new ex19_1();obj19_1.}public void method(int x,int y){System.out.println(______);System.out.println(______);}}
考题
类Test定义如下,将下列______方法插入③行处是不合法的。 ( )①public class Test{②public float Method(float a,float b){}③④}A.public float Method(float a,float b,float c){}B.public float Method(float c,float d){}C.public int Method(int a,int b){}D.private float Method(int a,int b,int c){}
考题
阅读下列代码段,选出该代码段的正确的文件名( )。 class A { void method () { System.out.println ("methodl in class A"); } } public class B { void method2 () { System.out.println("method2 in class B"); } public static void main (String args[]) { System.out.println ("main () in class B"); } }A.A.javaB.A.classC.B.classD.B.java
考题
2下列程序的执行结果是( )。 public class ex68 { public static void main(String[] args) { ex68 bj=new ex680; int s=0; for(int i=1; i<=4; i++){ s+=obj.method(i); } System.out.println(s); } public int method(int n) { if(n==1) return 1; else tatum n * method(n-1); } }A.3B.9C.33D.153
考题
阅读下列代码段,选出该代码段的正确的文件名 ( )class A{ void methodl(){ System.out.println("methodl in class A"); }}public class B{ void method2(){ System.out.println("method2 in class B"); } public static void main(String args[]){ System.out.println("main()in class B"); }}A.A.javaB.A.classC.B.classD.B.java
考题
下列程序的执行结果是 ( ) public class ex68{ public static void main(String[]args){ ex68 obj=new ex68(); int s=0; for(int i=1;i<=4;i++){ s+=obj.method(i); } System.out.println(s); } public int method(int n){ if(n==1) return 1; else return n*method(n-1); } }A.3B.9C.33D.153
考题
下列程序中,给出两个整数2和3,分别求2除以3和2乘以3的结果,要求调用类ex1_1的方法method()来输出相应的结果,请将程序补充完整。程序运行结果如下:0.66666666666666666public class ex1_1{public static void main(String[]args) {int n1=2,n2=3;ex1_1 obj1_1=new ex1_1();obj1_1. ______;}public void method(int x,int y){System.out.println(______);System.out.println(______);}}
考题
类Test定义如下,将下列哪个方法插入③行处是不合法的( )?① public class Test{② public float Method(float a,float B) { }③ ______④ }A.public float Method(float a,float b,float C) { }B.public float Method(float c,float d){ }C.public int Method(int a,int B) { }private float Method(int a,int b,int C) { }D.private float Method(int a,int b,int C) { }
考题
下列程序的运行结果为______。 class A { int b=0; } public class ex35 public static void main(String args[]) { ex35 t=new ex35(); t.method(); } void method() { A A1=new A(); A A2=new A(); A1,b=A2.b=12; boolean b=A1.equals(A2); Syatem.out.println(b); } }A.trueB.falseC.0D.1
考题
以下程序的输出结果为:public class test {public static void main(String args[]) {int s=0;for (int k=0;ks+=method(2,k)-1;System.out.println(s);}public static int method(int n,int m) {if (m==0)return 1;elsereturn n*method(n,m-1、;}}A. 2048B. 1024C. 2036D.2000
考题
设有程序如下: abstract class absclass { abstract void method1(); } class conclass extends absclass { public void method1() { System.out.println("子类");} } public class mainclass { public static void main(String args[]) { absclass ac1=new absclass(); //语句1 absclass ac2=new conclass(); //语句2 ac2.method1(); //语句3 } } 则main()方法中的第一条语句(即语句1)可以顺利通过编译。()此题为判断题(对,错)。
考题
阅读下列说明和 Java 代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
生成器( Builder)模式的意图是将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。图 6-1 所示为其类图。
阅读下列说明和C++代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
???? 生成器(Builder)模式的意图是将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。图5-1所示为其类图。
?
【C++代码】
#include
#include
using namespace std;
class Product {
private:?
string partA, partB;
public:?
Product() {?? }? ?
void setPartA(const string}
???? void setPartB(const string}? ?
//? 其余代码省略
};
class Builder {
public:? ? ??
(1)??
;?
virtual void buildPartB()=0;? ? ?
(2)??
;
};
class ConcreteBuilder1 : public Builder {
private:?
Product*?? product;
public:
ConcreteBuilder1() {product = new Product();???? }
void buildPartA() {????? (3)???? ("Component
A"); }?
void buildPartB() {????? (4)???? ("Component
B"); }??
Product* getResult() { return product; }
//? 其余代码省略
};
class ConcreteBuilder2 : public Builder {? ??? ? ? ?
/*??? 代码省略??? */
};
class Director {
private:? ??
Builder* builder;
public:??
Director(Builder* pBuilder) { builder= pBuilder;}? ??
void construct() {
????????????????? (5)???? ;
?????????????? //? 其余代码省略? ?
}??
//? 其余代码省略
};
int main() {? ? ??
Director* director1 = new Director(new ConcreteBuilder1());? ?
director1->construct();? ? ??
delete director1;? ? ?
return 0;
【Java代码】
import jav(6)A.util.*;
class Product {? ? ? ?
private String partA;? ? ? ?
private String partB;? ? ? ??
public Product() {}? ? ??
public void setPartA(String s) { partA = s; }? ? ? ?
public void setPartB(String s) { partB = s; }
}
interface Builder {? ?
public?????? (1)???? ;? ??
public void buildPartB();? ? ??
public?????? (2)???? ;
}
class ConcreteBuilder1 implements Builder {? ? ? ?
private Product product;? ? ? ?
public ConcreteBuilder1() { product = new Product();?? }? ? ? ??
public void buildPartA() {????????
(3)??
("Component A"); }
public void buildPartB() {???? ????(4)?? ("Component B"); }? ? ??
public Product getResult() { return product;}
}
class ConcreteBuilder2 implements Builder {?? ? ? ? ?
//? 代码省略
}
class Director {? ? ? ?
private Builder builder;? ? ? ?
public Director(Builder builder) {this.builder = builder; }
public void construct() {
? ? ? ? ? ? ? ? ? (5)???? ;
? ? ? ? ? ? ? //? 代码省略? ? ??
}
}
class Test {? ? ??
public static void main(String[] args) {
???????????????? Director director1 = new
Director(new ConcreteBuilder1());
???????????????? director1.construct();? ? ? ??
}
考题
A programmer needs to create a logging method that can accept an arbitrary number of arguments.Forexample,it may be called in these ways: logIt("log message 1"); logIt("log message 2”,”log message 3"); logIt("log message 4","log message 5","log message 6"); Which declaration satisfies this requirement()?A、public void logIt(String*msgs)B、public void logIt(String[]msgs)C、public void logIt(String...msgs)D、public voidl ogIt(Stringmsg1,Stringmsg2,Stringmsg3)
考题
对于下列代码: 1) class Person { 2} public void printValue(int i, int j) {//... } 3} public void printValue(int i){//... } 4} } 5) public class Teacher extends Person { 6} public void printValue( ) {//... } 7} public void printValue(int i) {//...} 8} public static void main(String args[]){ 9} Person t = new Teacher( ); 10} t.printValue(10); 11} } 第10行语句将调用哪行语句?()A、 line 2B、 line 3C、 line 6D、 line 7
考题
A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways: logIt(”log message 1 “); logIt(”log message2”,”log message3”); logIt(”log message4”, “log message5”, “log message6); Which declaration satisfies this requirement?()A、 public void logIt(String * msgs)B、 public void logIt(String [] msgs)C、 public void logIt(String... msgs)D、 public void logIt(String msg1, String msg2, String msg3)
考题
1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call? () A、 on line 2B、 on line 3C、 on line 6D、 on line 7
考题
public class TestFive { private int x; public void foo() { int current = x; x = current + 1; } public void go() { for(int i=0;i5;i++) { new Thread() { public void run() { foo(); System.out.print(x + “, “); } }.start(); }}} Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()A、 Move the line 12 print statement into the foo() method.B、 Change line 7 to public synchronized void go() {.C、 Change the variable declaration on line 3 to private volatile int x;.D、 Wrap the code inside the foo() method with a synchronized( this ) block.E、 Wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.
考题
单选题1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call? ()A
on line 2B
on line 3C
on line 6D
on line 7
考题
多选题1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call?()Aon line 2Bon line 3Con line 6Don line 7
考题
多选题public class TestFive { private int x; public void foo() { int current = x; x = current + 1; } public void go() { for(int i=0;i5;i++) { new Thread() { public void run() { foo(); System.out.print(x + “, “); } }.start(); }}} Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()AMove the line 12 print statement into the foo() method.BChange line 7 to public synchronized void go() {.CChange the variable declaration on line 3 to private volatile int x;.DWrap the code inside the foo() method with a synchronized( this ) block.EWrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.
考题
单选题A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways: logIt(”log message 1 “); logIt(”log message2”,”log message3”); logIt(”log message4”, “log message5”, “log message6); Which declaration satisfies this requirement?()A
public void logIt(String * msgs)B
public void logIt(String [] msgs)C
public void logIt(String... msgs)D
public void logIt(String msg1, String msg2, String msg3)
热门标签
最新试卷