niusouti.com

设有类定义如下:class InOut{String s= new String("Between");public void amethod(final int iArgs){int iam;class Bicycle{public void sayHello(){//Here}}}public void another(){int iOther;}}以下哪些语句可以安排在//Here处 ?A. System.out.println(s);B.System.out.println(iOther);C.

题目

设有类定义如下:

class InOut{

String s= new String("Between");

public void amethod(final int iArgs){

int iam;

class Bicycle{

public void sayHello(){

//Here

}

}

}

public void another(){

int iOther;

}

}

以下哪些语句可以安排在//Here处 ?

A. System.out.println(s);

B.System.out.println(iOther);

C. System.out.println(iam);

D. System.out.println(iArgs);


相似考题
更多“设有类定义如下:class InOut{String s= new String("Between");public void ametho ”相关问题
  • 第1题:

    下列程序的执行结果是 public class Testff{ public static void main(String args[]){ String sl=new String("I am boy"); String s2=new String("I am boy"); System.out.println(sl==s2); } }

    A.真

    B.假

    C.I am boy

    D.都不正确


    正确答案:B
    解析:在Java语言中,“==”不仅可以用于基本数据类型之间的比较,还可以用于复合数据类型之间的比较。对于复合类型的“==”运算,其比较的目标是两个操作数是否是同一个对象,虽然题目中,a1和s2的值都是Iamboy,但是它们是不同的对象,比较后的结果应是false。如果需要比较两个对象的值是否相等,可以用equals()方法。

  • 第2题:

    public class Something {

    public static void main(String[] args) {

    Something s = new Something();

    System.out.println("s.doSomething() returns " + doSomething());

    }

    public String doSomething() {

    return "Do something ...";

    }

    }

    看上去很完美。


    正确答案:

     

    错。看上去在main 里call doSomething 没有什么问题,毕竟两个methods 都在同一个

    class 里。但仔细看,main 是static 的。static method 不能直接call non-static methods。可改

    成"System.out.println("s.doSomething() returns " + s.doSomething());"。同理,static method 不

    能访问non-static instant variable。

  • 第3题:

    下列语句输出结果为( )。 public class test { public static void main(StringArgsl[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); } }

    A.false

    B.true

    C.1

    D.0


    正确答案:B

  • 第4题:

    有如下代码段 public class OperatorAndExceptions { public static void main(String args[ ] { int i=10,j=15; System.out.println(i==j); String s1 = new String("how are you!"); String s2=new String("how are you!"); System.out.println(s1==s2); } } 其输出为( )。

    A.true false

    B.true true

    C.false true

    D.false false


    正确答案:D
    解析:本题考查比较运算符==的使用。比较运算符不仅可以用于基本数据类型的数据之间的比较,还可以用于复合数据类型的数据之间的比较。题中整型数i和j的值不同,故其==比较的结果为false。s1和s2的值虽然都是“howareyou!”,但是由于它们是不同的对象,因此运算后的结果为false。如果需要比较两个对象的值是否相同,则可以调用equals()方法。

  • 第5题:

    以下程序的调试结果为?

    public class Outer{

    public String name = "Outer";

    public static void main(String argv[]){

    Inner i = new Inner();

    i.showName();

    }

    private class Inner{

    String name =new String("Inner");

    void showName(){

    System.out.println(name);

    }

    }

    }

    A.输出结果 Outer

    B.输出结果 Inner

    C.编译错误,因Inner类定义为私有访问

    D.在创建Inner类实例的行出现编译错误


    正确答案:D

  • 第6题:

    设有程序如下: public class jzh0319 { public static void main(String args[]) { subClass sc=new subClass(); } } class superClass { superClass() { System.out.println("父类");} } class subClass extends superClass { subClass() {System.out.println("子类"); } } 其输出结果只有一行。()

    此题为判断题(对,错)。


    答案:错

  • 第7题:

    Public class test (  Public static void stringReplace (String text)  (  Text = text.replace (‘j’ , ‘i’);  )  public static void bufferReplace (StringBuffer text)  (  text = text.append (“C”)  )   public static void main (String args[]}  (  String textString = new String (“java”);  StringBuffer text BufferString = new StringBuffer (“java”);  stringReplace (textString);  BufferReplace (textBuffer);  System.out.printLn (textString + textBuffer);  )  )   What is the output?()


    正确答案:JAVAJAVA

  • 第8题:

    public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()

    • A、 public void aMethod() {}
    • B、 private void aMethod() {}
    • C、 public void aMethod(String s) {}
    • D、 private Y aMethod() { return null; }
    • E、 public X aMethod() { return new Y(); }

    正确答案:C,E

  • 第9题:

    public class X {   public static void main (Stringargs) {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s) {   s += “world!”;   }   }   What is the result?() 

    • A、The program runs and prints “Hello”
    • B、An error causes compilation to fail.
    • C、The program runs and prints “Hello world!”
    • D、The program runs but aborts with an exception.

    正确答案:A

  • 第10题:

    单选题
    现有:  class Tree {  private static String tree = "tree ";  String getTree ()  {  return tree;  }       }  class Elm extends Tree {  private static String tree = "elm ";  public static void main (String  []  args)  {       new Elm() .go (new Tree())  ;      } }  void go (Tree t)  {  String  s =  t.getTree () +Elm.tree  +  tree  +   (new  Elm() .getTree ()) ;      System.out.println (s) ;}     结果为:()
    A

     elm elm elm elm

    B

     tree elm elm elm

    C

     tree elm elm tree

    D

     tree elm tree elm


    正确答案: D
    解析: 暂无解析

  • 第11题:

    单选题
    final class Tree {  private static String tree = "tree ";  String getTree() { return tree; }  }  class Elm extends Tree {  private static String tree = "elm "; public static void main(String [] args) {  new Elm().go(new Tree());  }  void go(Tree t) {  String s = t.getTree()+Elm.tree+tree+(new Elm().getTree());  System.out.println(s);  } }  结果为:()
    A

    elm elm elm elm

    B

    tree elm elm elm

    C

    tree elm tree elm

    D

    编译失败


    正确答案: C
    解析: 暂无解析

  • 第12题:

    单选题
    public class X {   public static void main (String[]args)   {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s)  {   s += “world!”;      }   }      What is the result?()
    A

     The program runs and prints “Hello”

    B

     An error causes compilation to fail.

    C

     The program runs and prints “Hello world!”

    D

     The program runs but aborts with an exception.


    正确答案: D
    解析: 暂无解析

  • 第13题:

    下列代码的执行结果是( )。 public class Test{ public static void main String args[]){ String s1=new String("welcome"); String s2=new String("welcome"); System.out.println(s1==s2); System.out.println(s1.equals(s2)); } }

    A.false,false

    B.false,true

    C.true,true

    D.true,false


    正确答案:B

  • 第14题:

    阅读下面程序 public class OperatorsAndExpressions { void equalsMethodl(){ String s1=new String("how are you"); String s2=new String("how are you"); System.out.println(s1==s2); } public static void main(String args[]){ OperatorsAndExpressions perAndExp=new OperatorsAndExpressions(); OperAndExp.equalsMethod1(); } } 程序运行结果是( )。

    A. ==

    B.true

    C.假

    D.equal


    正确答案:C

  • 第15题:

    下列代码段的执行结果是( )。 public class Test { public static void main(String args[ ]) { String s1= new String("hello"); String s2= new String("hello"); System.out.println(s1==s2); System.out.println(s1.equal(s2)); } }

    A.true false

    B.true true

    C.false true

    D.false false


    正确答案:C
    解析:本题考查比较运算符(==)的使用。比较运算符不仅可以用于基本数据类型的数据之间的比较,还可以用于复合数据类型的数据之间的比较。题中s1和s2的值虽然都是hello,但是由于它们是不同的对象,因此运算后的结果为false。如果需要比较两个对象的值是否相同,则可以调用equals()方法。所以程序最后输出false和true。

  • 第16题:

    下列程序通过实现Runnable接口创建一个线程,选择正确的语句填入程序的横线处。 class MyRun implements Runnable { String str; MyRun(String s) { str = s; } public void run() System.out.println(str); } } public class ex40 { public static void main(String[] args) { String name = "实现阶段Runnable 接口"; MyRun my = new MyRun(name); Thread th = th. start ( ); } }

    A.new MyRun(my)

    B.new Thread()

    C.new Thread(my)

    D.Thread(my)


    正确答案:C

  • 第17题:

    设有类定义如下:

    class Base{

    public Base(int i){}

    }

    public class MyOver extends Base{

    public static void main(String arg[]){

    MyOver m = new MyOver(10);

    }

    MyOver(int i){

    super(i);

    }

    MyOver(String s, int i){

    this(i);

    //Here

    }

    }

    以下哪条语句可以安排在//Here处 ?

    A.MyOver m = new MyOver();

    B.super();

    C.this("Hello",10);

    D.Base b = new Base(10);


    正确答案:D

  • 第18题:

    设有程序如下: public class jzh0319 { public static void main(String args[]) { subClass sc=new subClass(); } } class superClass { superClass() { System.out.println("父类");} } class subClass extends superClass { subClass() {System.out.println("子类"); } } 其输出结果的第一行是:父类。()

    此题为判断题(对,错)。


    答案:对

  • 第19题:

    Which two allow the class Thing to be instantiated using new Thing()?

    • A、 public class Thing { }
    • B、 public class Thing { public Thing() {} }
    • C、 public class Thing { public Thing(void) {} }
    • D、 public class Thing { public Thing(String s) {} }
    • E、 public class Thing { public void Thing() {} public Thing(String s) {} }

    正确答案:A,B

  • 第20题:

     public class X {   public static void main (String[]args)   {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s)  {   s += “world!”;      }   }      What is the result?()    

    • A、 The program runs and prints “Hello”
    • B、 An error causes compilation to fail.
    • C、 The program runs and prints “Hello world!”
    • D、 The program runs but aborts with an exception.

    正确答案:A

  • 第21题:

    单选题
    public class X {   public static void main (Stringargs) {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s) {   s += “world!”;   }   }   What is the result?()
    A

    The program runs and prints “Hello”

    B

    An error causes compilation to fail.

    C

    The program runs and prints “Hello world!”

    D

    The program runs but aborts with an exception.


    正确答案: D
    解析: 暂无解析

  • 第22题:

    多选题
    Which two allow the class Thing to be instantiated using new Thing()?
    A

    public class Thing { }

    B

    public class Thing { public Thing() {} }

    C

    public class Thing { public Thing(void) {} }

    D

    public class Thing { public Thing(String s) {} }

    E

    public class Thing { public void Thing() {} public Thing(String s) {} }


    正确答案: E,A
    解析: 暂无解析

  • 第23题:

    填空题
    Public class test (    Public static void stringReplace (String text) (    Text = text.replace („j„ , „i„);    )      public static void bufferReplace (StringBuffer text) (    text = text.append (“C”)   )      public static void main (String args ){  String textString = new String (“java”);    StringBuffer text BufferString = new StringBuffer (“java”);      stringReplace (textString);    BufferReplace (textBuffer);      System.out.printIn (textString + textBuffer);    }   )   What is the output?()

    正确答案: javajavaC
    解析: 暂无解析