首页/ 题库 / [单选题]

public void test的答案

public void testIfA(){
if(testIfB("True")){
System.out.println("True");
}else{
System.out.println("Nottrue");
}
}
public Boolean testIfB(Stringstr){
return Boolean.valueOf(str);
}
What is the result when method testIfA is invoked?()

单选题
2022-01-06 02:43
A、True
B、Nottrue
C、Anexceptionisthrownatruntime.
D、Compilationfailsbecauseofanerroratline12.
E、Compilationfailsbecauseofanerroratline19.
查看答案

正确答案
A

试题解析

感兴趣题目

public void testIfA(){
if(testIfB("True")){
System.out.println("True");
}else{
System.out.println("Nottrue");
}
}
public Boolean testIfB(Stringstr){
return Boolean.valueOf(str);
}
What is the result when method testIfA is invoked?()

public static void main(String[]args){
for(inti=0;i<=10;i++){
if(i>6)break;
}
System.out.println(i);
}
What is the result?()

给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test {  public void cal(int x, int y, int z) { } //A } 

现有: 
interface Data {public void load();} 
abstract class Info {public abstract void load();}     
下列类定义中正确使用Data和Info的是哪项?() 

public class Team extends java.util.LinkedList {  public void addPlayer(Player p) {  add(p);  }  public void compete(Team opponent) { /* more code here */ }  }  class Player { /* more code here */ }  Which two are true?()
下列代码的下画线处应填入的方法名是( )。 import java.awt.*; import java.applet.*; public class Hello extends Applet{ public void (Graphics g){ 9.drawstring("How are you!",l0,10); } }
关于下面的程序段,说法正确的是( )。 import java.awt.*; import java.applet.*; public class Test extends Applet { Canvas MyCanvas; public void init() { MyCanvas=new Canvas() MyCanvas.seBackSround(Color.cyan); add(MyCanvas); } }
关于下面的程序段,说法正确的是 import java.awt.*; import java.applet.*; public class Test extends Applet{ Canvas MyCanvas; public void init(){ MyCanvas=new Canvas(); MyCanvas.setBackground(Color.cyan); add(MyCanvas); } }
class java {  public static void main(String [] java) {   for (int Java = 1; Java 〈 java.length; Java++)   System.out.print("java ");   }   }   和命令行:  java java java java java   结果为:()  

class java { 
public static void main(String [] java) {  
for (int Java = 1; Java 〈 java.length; Java++)  
System.out.print("java ");  
}  
}  
和命令行: 
java java java java java  
结果为:()  

下面可作为public void aMethod(){...}重载方法的是(  )。

下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file " ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }
相关题目
有如下程序: class Base1 { public: int a; void b() { return}; void c(float) { a=float;} }; class Base2 { public: void b(){} void c(){} private: int a; }; class Derived:public Basel,public Base2 { public: void b(){} }; void main() { Derived obj; obj.a=1; //① obj.b(); //② obj.c(10); //③ } 下面各项对语句①②③的描述中,正确的是( )。
下面的代码中方法unsafe()有异常发生,那么可以加在第一行的语句为( )。 { if(unsafe()) { //do something } else if(safe()) { //do the other} } Ⅰ:public void methodName() Ⅱ:public void methodName() throw IOException Ⅲ:public void methodName() throws IOException Ⅳ:public void methodName() throws Exception
下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file " ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }
下面程序的运算结果是( )。 #include<iostream> using namespace std; class A { public: virtual void fun()=0; }; class B:public A } public: void fun() {cout<<"new file"<<" ";} }; class C:public A { public: void fun() { cout<<"open file"<<" ";} }; void main() { A a, * p; B b;C c; p=&c; p->fun(); p=&b; }
下列程序实现了2个监听器接口:ActionListener和W1ndowListener。 import java.awt.*; import java.awt.event.*; public class ex39______ { public static void main(String[] args) { ex39 bj = new ex39(); obj .go(); } public void go() { Frame. f = new Frame("ex39"); f.addWindowListener(this); Button b = new Button("Button"); b.addActionListener(this); f.add(b); f.pack(); f.setVisible(true); } public void actionPerformed(ActionEvent e) { System.out.println("Button pressed!"); } public void windowActivated(WindowEvent e){} public void windowDeactivated(WindowEvent e){} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e){System.exit(1); public void windowIconified(WindowEvent e){} public void windowDeiconified(WindowEvent e) {} public void windowOpened(WindowEvent e){} } 请选择正确的语句填入横线处。
下面程序的正确输出是(  )。
public class Hello
{
public static void main(String args[])
{
int count,xPos=25;
for(count=1;count<=10;count++)
{
if(count= =5)
Break;
system.Out.println(count);
xPos+=10:
}
}
}
阅读下列程序:
Public class Test implements Runnable{
Private int x=0l
Private int y=0;
boolean flag=true;
Public static void main(string[]args){
Test r=new Test();
Thead tl=new Thead(r);
Thead t2=new Thead(r);
tl.start();
t2.start();
}
Public void run(){
While(flag){
x++;
y++;
system.out.println("("+x-","+y+")");
if(x>=10)
flag=false;
}
}
}
下列对程序运行结果描述的选项中,正确的是(  )。
下列横线处应填写的语句是(  )。
import JaVa.awt.*;
public class FirstFrame extends Frame{
public static void main(String args[]){
FirstFrame fr=new FirstFrame("First container!");
fr.setsize(240,240);
fr.setBackground(Color.yellow);
}
public FirstFrame(String str){
super(str);
}
}
能将程序补充完整的选项是( )。
class Person
{
private int a;
public int change(int m){return m;)
}
public class Teacher extends Person
{
public int b;
public static void main(String arg[])
{
Person p=new Person();
Teacher t=new Teacher();
int i;

}
}

给出下列java源代码: 
//Point x 
Public class Interesting{} 
在源代码//point x处添加()能符合java语法 

阅读以下代码: 
public class Test{ 
public static void main(){ 
System.out.println(“x=”+x);   } } 
请问,代码运行的结果是?() 

下面程序的运算结果是( )。 #include<iostream> using namespace std; class A { public: virtual void fun()=0; }; class B:public A } public: void fun() {cout<<"new file"<<" ";} }; class C:public A { public: void fun() { cout<<"open file"<<" ";} }; void main() { A a, * p; B b;C c; p=&c; p->fun(); p=&b; }
Test.java程序代码如下: public class Test{ public static void main(String[] args){ System.out.println(args[1]); } } 以上程序编译后用java Test 2 3 4 5运行的输出结果是什么? ( )

1. class Pizza { 
2. java.util.ArrayList toppings; 
3. public final void addTopping(String topping) { 
4. toppings.add(topping);
5. } 
6. } 
7. public class PepperoniPizza extends Pizza { 
8. public void addTopping(String topping) { 
9. System.out.println(”Cannot add Toppings”); 
10. } 
11. public static void main(String[] args) { 
12. Pizza pizza = new PepperoniPizza(); 
13. pizza.addTopping(”Mushrooms”); 
14. } 
15. } 
What is the result?() 

1. public class SimpleCalc { 
2. public int value; 
3. public void calculate() { value += 7; } 
4. }
And: 
1. public class MultiCalc extends SimpleCalc { 
2. public void calculate() { value -= 3; } 
3. public void calculate(int multiplier) { 
4. calculate(); 
5. super.calculate(); 
6. value *=multiplier; 
7. } 
8. public static void main(String[] args) { 
9. MultiCalc calculator = new MultiCalc(); 
10. calculator.calculate(2); 
11. System.out.println(”Value is: “+ calculator.value); 
12. } 
13. } 
What is the result?() 

阅读下面程序 public class Cycle { public static void main(String[] args) { System.out.println(args[0]); } } 在命令行输入java Cycle one two,该程序输出的结果是
下面程序的输出结果是( )。 import java.awt.*; import java.applet.*; public class HelloApplet extends Applet { public void paint(Graphics g) { g.drawstring("Hello World!", 20, 20); } }
下面程序的输出结果是( )。 import java. awt.*; import java. applet.*; public class HelloApplet extends Applet { public void paint(Graphics g) { g.drawString("Hello World! ",20,20); } }
下面的代码中方法unsafe()有异常发生,那么可以加在第一行的语句为( )。 { if(unsafe()) { //do something } else if(safe()) { //do the other} } Ⅰ:public void methodName() Ⅱ:public void methodName() throw IOException Ⅲ:public void methodName() throws IOException Ⅳ:public void methodName() throws Exception

在J2EE中,有如下代码在Servlet1.Java中   
Import javax.servlet.*;   
Import javax.servlet.http.*   
Import java.io.IOException;    
Import java.io.PrintWriter;   
Public class Servlet1 extends HttpServlet{ 
Public void init () throw ServletException {}  
Public void service(HttpServletRequest request, 
HttpServletResponce response) throws ServletException,IOException{ 
PrintWriter out=response.getWriter();  
Out.println(“hello!”); } } 
假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下成熟正确的是()  

广告位招租WX:84302438

免费的网站请分享给朋友吧