网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

现有:  class Foo  {  public static void main (String  []  args)  {      int x=O;      int y=4;  for (int  z=0;  z<3;  Z++;  X++)  {     if(x>1&++y<10)    y++;    }  System. out .println (y);  }   }  结果是什么?()     

  • A、7
  • B、8
  • C、10
  • D、12

参考答案

更多 “ 现有:  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 Foo{public:Foo(int v):value(v){} // ①~Foo(){} // ②private:Foo(){} // ③int value = 0; // ④};其中存在语法错误的行是A . ①B . ②C . ③D . ④

考题 Given:Which code, inserted at line 15, allows the class Sprite to compile?() A.Foo { public int bar() { return 1; }B.new Foo { public int bar() { return 1; }C.new Foo() { public int bar() { return 1; }D.new class Foo { public int bar() { return 1; }

考题 有如下类定义: class Foo { public: Foo(intv):value(v){} //① ~Foo(){} //② private: Foo(){} //③ int value=0; //④ }; 其中存在语法错误的行是( )。A.①B.②C.③D.④

考题 A developer is creating a class Book that needs to access class Paper.The Paper class is deployed in a JARnamedmyLib.jar.Whichthree,taken independently,will allow the developer to use the Paper class while compiling the Book class?()A、The JAR fileis located at$JAVA_HOME/jre/classes/myLib.jar.B、The JAR fileis located at$JAVA_HOME/jre/lib/ext/myLib.jar.C、TheJ AR fileis located at/foo/myLib.jar and aclasspath environment variable is set that includes /foo/myLib.jar/Paper.class.D、The JAR fileis located at/foo/myLib.jar and a classpath environment variable is set that includes/foo/myLib.jar.E、The JAR file is located at/foo/myLib.jar and the Book class is compiled using javac-cp/foo/myLib.jar/Paper Book.java.F、The JAR file is located at/foo/myLib.jar and the Book class is compiled using javac-classpath/foo/myLib.jar Book.java.

考题 package foo;  public class Outer {  public static class Inner {  }  }   Which statement is true?() A、 Compilation fails.B、 An instance of the Inner class can be constructed with “new Outer.Inner()”.C、 An instance of the Inner class cannot be constructed outside of package foo.D、 An instance of the Inner class can be constructed only from within the Outer class.E、 From within the package foo, and instance of the Inner class can be constructed with “new Inner()”.

考题 public class Base {  public static final String FOO = “foo”;  public static void main(String[] args) {  Base b = new Base();  Sub s = new Sub();  System.out.print(Base.FOO);  System.out.print(Sub.FOO);  System.out.print(b.FOO);  System.out.print(s.FOO);  System.out.print(((Base)s).FOO);  } }  class Sub extends Base {public static final String FOO=bar;}  What is the result?() A、 foofoofoofoofooB、 foobarfoobarbarC、 foobarfoofoofooD、 foobarfoobarfooE、 barbarbarbarbarF、 foofoofoobarbarG、 foofoofoobarfoo

考题 class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()A、 int foo() { /* more code here */ }B、 void foo() { /* more code here */ }C、 public void foo() { /* more code here */ }D、 private void foo() { /* more code here */ }E、 protected void foo() { /* more code here */ }

考题 package foo; public class Outer (  public static class Inner (  )  )   Which statement is true? () A、 An instance of the Inner class can be constructed with “new Outer.Inner ()”B、 An instance of the inner class cannot be constructed outside of package foo.C、 An instance of the inner class can only be constructed from within the outer class.D、 From within the package bar, an instance of the inner class can be constructed with “new inner()”

考题 class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  Which two methods, inserted individually, correctly complete the Three class?()A、 public void foo() { }B、 public int foo() { return 3; }C、 public Two foo() { return this; }D、 public One foo() { return this; }E、 public Object foo() { return this; }

考题 Which statements concerning the relationships between the following classes are true?()   class Foo {  int num;   Baz comp = new Baz();   }   class Bar {  boolean flag;   }   class Baz extends Foo {   Bar thing = new Bar();   double limit;   }  A、A Bar is a Baz.B、A Foo has a Bar.C、A Baz is a Foo.D、A Foo is a Baz.E、A Baz has a Bar.

考题 public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()  A、 i = 3B、 Compilation fails.C、 A ClassCastException is thrown at line 6.D、 A ClassCastException is thrown at line 7.

考题 public class Foo {  public int a;  public Foo() { a = 3; }  public void addFive() { a += 5; }  }  and:  public class Bar extends Foo { public int a;  public Bar() { a = 8; }  public void addFive() { this.a +=5; }  }  invoked with:  Foo foo = new Bar();  foo.addFive();  System.out.println(”Value: “+ foo.a);  What is the result?() A、 Value: 3B、 Value: 8C、 Value: 13D、 Compilation fails.E、 The code runs with no output.F、 An exception is thrown at runtime.

考题 单选题public class Foo {  public int a;  public Foo() { a = 3; }  public void addFive() { a += 5; }  }  and:  public class Bar extends Foo { public int a;  public Bar() { a = 8; }  public void addFive() { this.a +=5; }  }  invoked with:  Foo foo = new Bar();  foo.addFive();  System.out.println(”Value: “+ foo.a);  What is the result?()A  Value: 3B  Value: 8C  Value: 13D  Compilation fails.E  The code runs with no output.F  An exception is thrown at runtime.

考题 多选题Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()Apublic void foo() { /* more code here */ }Bprivate void foo() { /* more code here */ }Cprotected void foo() { /* more code here */ }Dint foo() { /* more code here */ }Evoid foo() { /* more code here */ }

考题 多选题class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()Aint foo() { /* more code here */ }Bvoid foo() { /* more code here */ }Cpublic void foo() { /* more code here */ }Dprivate void foo() { /* more code here */ }Eprotected void foo() { /* more code here */ }

考题 多选题Which statements concerning the relationships between the following classes are true?()   class Foo {  int num;   Baz comp = new Baz();   }   class Bar {  boolean flag;   }   class Baz extends Foo {   Bar thing = new Bar();   double limit;   }AA Bar is a Baz.BA Foo has a Bar.CA Baz is a Foo.DA Foo is a Baz.EA Baz has a Bar.

考题 单选题public class Test {   public static void main (String args) {   class Foo {   public int i = 3;  }   Object o = (Object) new Foo();   Foo foo = (Foo)o;   System.out.printIn(foo. i);  }   }   What is the result?()A  Compilation will fail.B  Compilation will succeed and the program will print “3”C  Compilation will succeed but the program will throw a ClassCastException at line 6.D  Compilation will succeed but the program will throw a ClassCastException at line 7.

考题 单选题10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?()A  Foo { public int bar() { return 1; } }B  new Foo { public int bar() { return 1; } }C  newFoo() { public int bar(){return 1; } }D  new class Foo { public int bar() { return 1; } }

考题 多选题A developer is creating a class Book that needs to access class Paper.The Paper class is deployed in a JARnamedmyLib.jar.Whichthree,taken independently,will allow the developer to use the Paper class while compiling the Book class?()AThe JAR fileis located at$JAVA_HOME/jre/classes/myLib.jar.BThe JAR fileis located at$JAVA_HOME/jre/lib/ext/myLib.jar.CTheJ AR fileis located at/foo/myLib.jar and aclasspath environment variable is set that includes /foo/myLib.jar/Paper.class.DThe JAR fileis located at/foo/myLib.jar and a classpath environment variable is set that includes/foo/myLib.jar.EThe JAR file is located at/foo/myLib.jar and the Book class is compiled using javac-cp/foo/myLib.jar/Paper Book.java.FThe JAR file is located at/foo/myLib.jar and the Book class is compiled using javac-classpath/foo/myLib.jar Book.java.

考题 多选题A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar. Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class?()AThe JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.BThe JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar..CThe JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar/Paper.class.DThe JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar.EThe JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -cp /foo/myLib.jar/Paper Book.java.FThe JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d /foo/myLib.jar Book.javaGThe JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -classpath /foo/myLib.jar Book.java

考题 单选题public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()A  i = 3B  Compilation fails.C  A ClassCastException is thrown at line 6.D  A ClassCastException is thrown at line 7.

考题 单选题package foo; public class Outer (  public static class Inner (  )  )   Which statement is true? ()A  An instance of the Inner class can be constructed with “new Outer.Inner ()”B  An instance of the inner class cannot be constructed outside of package foo.C  An instance of the inner class can only be constructed from within the outer class.D  From within the package bar, an instance of the inner class can be constructed with “new inner()”

考题 单选题现有:  1.class SuperFoo{  2.SuperFoo doStuff (int x)  {      3.return new SuperFoo();      4.    }      5.  }      6.  7. class Foo extends SuperFoo  {     8.    //insert code here     9.  }  和四个声明:   Foo doStuff (int x)  {  return new Foo();  }  Foo doStuff (int x)  {  return new SuperFoo();  }      SuperFoo doStuff(int x)  {  return new Foo();  }  SuperFoo doStuff(int y)  {  return new SuperFoo();  }    分别插入到第8行,有几个可以通过编泽?()A  1B  2C  3D  4

考题 多选题A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar.  Which three, taken independently, will allow the developer to use the Paper class while compiling the Bookclass?()AThe JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.BThe JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar..CThe JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar/Paper.class.DThe JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar.EThe JAR file is located at /foo/myLib.jar and the Book class is compiled using javac - cp /foo/myLib.jar/Paper Book.java.FThe JAR file is located at /foo/myLib.jar and the Book class is compiled using javac - classpath /foo/myLib.jar Book.java

考题 单选题package foo;  public class Outer {  public static class Inner {  }  }   Which statement is true?()A  Compilation fails.B  An instance of the Inner class can be constructed with “new Outer.Inner()”.C  An instance of the Inner class cannot be constructed outside of package foo.D  An instance of the Inner class can be constructed only from within the Outer class.E  From within the package foo, and instance of the Inner class can be constructed with “new Inner()”.

考题 多选题A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar. Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class?()AThe JAR file is located at $JAVA_HOME/jre/classes/myLib.jarBThe JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jarCThe JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar/Paper.classDThe JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jarEThe JAR file is located at /foo/myLib.jar and the Book class is compiled using javac –cp /foo/myLib.jar/Paper Book.javaFThe JAR file is located at foo/myLib.jar and the Book class is compiled using javac –classpath /foo/myLib.jar Book.java

考题 单选题public class Base {  public static final String FOO = “foo”;  public static void main(String[] args) {  Base b = new Base();  Sub s = new Sub();  System.out.print(Base.FOO);  System.out.print(Sub.FOO);  System.out.print(b.FOO);  System.out.print(s.FOO);  System.out.print(((Base)s).FOO);  } }  class Sub extends Base {public static final String FOO=bar;}  What is the result?()A  foofoofoofoofooB  foobarfoobarbarC  foobarfoofoofooD  foobarfoobarfooE  barbarbarbarbarF  foofoofoobarbarG  foofoofoobarfoo

考题 多选题class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  Which two methods, inserted individually, correctly complete the Three class?()Apublic void foo() { }Bpublic int foo() { return 3; }Cpublic Two foo() { return this; }Dpublic One foo() { return this; }Epublic Object foo() { return this; }