package foo; import java.util.Vector; private class MyVector extends Vector { int i = 1; public MyVector() { i = 2; } } public class MyNewVector extends MyVector { public MyNewVector () { i = 4; } public static void main (String args ) { MyVector v = new MyNewVector(); } } The file MyNewVector.java is shown in the exhibit. What is the result?()A、 Compilation will succeed.B、 Compilation will fail at line 5.C、 Compilation will fail at line 6.D、 Compilation will fail at line 14.E、 Compilation will fail at line 17.
package foo; import java.util.Vector; private class MyVector extends Vector { int i = 1; public MyVector() { i = 2; } } public class MyNewVector extends MyVector { public MyNewVector () { i = 4; } public static void main (String args ) { MyVector v = new MyNewVector(); } } The file MyNewVector.java is shown in the exhibit. What is the result?()
- A、 Compilation will succeed.
- B、 Compilation will fail at line 5.
- C、 Compilation will fail at line 6.
- D、 Compilation will fail at line 14.
- E、 Compilation will fail at line 17.
相关考题:
package com.sun.sjcp;public class Commander{public static void main(String[]args){//more code here}}Assume that the class fileis located in /foo/com/sun/sjcp/,the current directory is/foo/,and that the classpath contains.(current directory).Which command line correctly runs Commander?()A.java CommanderB.java com.sim.sjcp.CommanderC.java com/sun/sjcp/CommanderD.java-cpcom.sun.sjcp CommanderE.java-cpcom/sun/sjcp Commander
publicclassDelta{staticbooleanfoo(charc){System.out.print(c);returntrue;}publicstaticvoidmain(String[]argv){inti=0;for(foo(‘A’);foo(‘B’)(i2);foo(‘C’)){i++;foo(‘D’);}}}Whatistheresult?() A.ABDCBDCBB.ABCDABCDC.Compilationfails.D.Anexceptionisthrownatruntime.
publicclassTest{publicstaticvoidmain(Stringargs[]){classFoo{publicinti=3;}Objecto=(Object)newFoo();Foofoo=(Foo)o;System.out.println(i=+foo.i);}}Whatistheresult?() A.i=3B.Compilationfails.C.AClassCastExceptionisthrownatline6.D.AClassCastExceptionisthrownatline7.
publicclassTest{publicstaticvoidmain(Stringargs){classFoo{publicinti=3;}Objecto=(Object)newFoo();Foofoo=(Foo)o;System.out.printIn(foo.i);}}Whatistheresult?() A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“3”C.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline6.D.CompilationwillsucceedbuttheprogramwillthrowaClassCastExceptionatline7.
A package contains nitric acid solution and is radioactive.The radiation level at the package surface is 36 millirems per hour.How should this package be labeled ________.A.Radioactive II and oxidizerB.Radioactive II and poisonC.Radioactive I and corrosiveD.Fissile class I
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 Foo { public static void main (String args) { int i = 1; int j = i++; if ((i++j) (i++ ==j)) { i +=j; } } } What is the final value of i?() A、 1B、 2C、 3D、 4E、 5
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()”
package foo; import java.util.Vector; private class MyVector extends Vector { int i = 1; public MyVector() { i = 2; } } public class MyNewVector extends MyVector { public MyNewVector() { i = 4; } public static void main(String args[]) { MyVector v = new MyNewVector(); } } What is the result?()A、 Compilation succeeds.B、 Compilation fails because of an error at line 5.C、 Compilation fails because of an error at line 6.D、 Compilation fails because of an error at line 14.E、 Compilation fails because of an error at line 17.
public class Delta { static boolean foo(char c) { System.out.print(c); return true; } public static void main( String[] argv ) { int i =0; for ( foo(‘A’); foo(‘B’)(i2); foo(‘C’)){ i++ ; foo(‘D’); } } } What is the result?() A、 ABDCBDCBB、 ABCDABCDC、 Compilation fails.D、 An exception is thrown at runtime.
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.
1.public class Test { 2.public static void main (String args[]) { 3.class Foo { 4.public int i = 3; 5.} 6.Object o = (Object) new Foo(); 7.Foo foo = (Foo)o; 8.System.out.printIn(foo. i); 9. } 10.} 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.
interface foo { int k = 0; } public class test implements Foo ( public static void main(String args) ( int i; Test test = new test (); i= test.k; i= Test.k; i= Foo.k; ) ) What is the result? ()A、 Compilation succeeds.B、 An error at line 2 causes compilation to fail.C、 An error at line 9 causes compilation to fail.D、 An error at line 10 causes compilation to fail.E、 An error at line 11 causes compilation to fail.
单选题interface foo { int k = 0; } public class test implements Foo ( public static void main(String args) ( int i; Test test = new test (); i= test.k; i= Test.k; i= Foo.k; ) ) What is the result? ()A Compilation succeeds.B An error at line 2 causes compilation to fail.C An error at line 9 causes compilation to fail.D An error at line 10 causes compilation to fail.E An error at line 11 causes compilation to fail.
单选题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.
单选题1. interface foo { 2. int k = 0; 3. } 4. 5. public class test implements Foo ( 6. public static void main(String args[]) ( 7. int i; 8. Test test = new test (); 9. i= test.k; 10.i= Test.k; 11.i= Foo.k; 12.) 13.) 14. What is the result?()A Compilation succeeds.B An error at line 2 causes compilation to fail.C An error at line 9 causes compilation to fail.D An error at line 10 causes compilation to fail.E An error at line 11 causes compilation to fail.
单选题package foo; import java.util.Vector; private class MyVector extends Vector { int i = 1; public MyVector() { i = 2; } } public class MyNewVector extends MyVector { public MyNewVector () { i = 4; } public static void main (String args ) { MyVector v = new MyNewVector(); } } The file MyNewVector.java is shown in the exhibit. What is the result?()A Compilation will succeed.B Compilation will fail at line 5.C Compilation will fail at line 6.D Compilation will fail at line 14.E Compilation will fail at line 17.
单选题package com.sun.sjcp; public class Commander{ public static void main(String[]args){ //more code here } } Assume that the class fileis located in /foo/com/sun/sjcp/,the current directory is/foo/,and that the classpath contains“.“(current directory). Which command line correctly runs Commander?()Ajava CommanderBjava com.sim.sjcp.CommanderCjava com/sun/sjcp/CommanderDjava-cpcom.sun.sjcp CommanderEjava-cpcom/sun/sjcp Commander
单选题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 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 }.
单选题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()”
单选题A package contains nitric acid solution and is radioactive. The radiation level at the package surface is 36 millirems per hour. How should this package be labeled? ()ARadioactive II and oxidizerBRadioactive II and poisonCRadioactive I and corrosiveDFissile class I
单选题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()”.
单选题Unfortunately, the package I was expecting was _____ to the wrong address.AwrittenBgivenCpackedDdelivered
单选题public class Delta { static boolean foo(char c) { System.out.print(c); return true; } public static void main( String[] argv ) { int i =0; for ( foo(‘A’); foo(‘B’)(i2); foo(‘C’)){ i++ ; foo(‘D’); } } } What is the result?()A ABDCBDCBB ABCDABCDC Compilation fails.D An exception is thrown at runtime.
单选题1.public class Test { 2.public static void main (String args[]) { 3.class Foo { 4.public int i = 3; 5.} 6.Object o = (Object) new Foo(); 7.Foo foo = (Foo)o; 8.System.out.printIn(foo. i); 9. } 10.} 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.