Consider the following class: class Test(int i) { void test(int i) { System.out.println(“I am an int.”); } void test(String s) { System.out.println(“I am a string.”); } public static void main(String args) { Test t=new Test(); char ch=“y”; t.test(ch); } } Which of the statements below is true?()
A、 Line 5 will not compile, because void methods cannot be overridden.
B、 Line 12 will not compile, because there is no version of test() that rakes a charargument.
C、 The code will compile but will throw an exception at line 12.
D、 The code will compile and produce the following output: I am an int.
E、 The code will compile and produce the following output: I am a String.
相关问题推荐
-
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?()
Apublic void aMethod() {}
Bprivate void aMethod() {}
Cpublic void aMethod(String s) {}
Dprivate Y aMethod() { return null; }
Epublic X aMethod() { return new Y(); }
-
Which method in the Thread class is used to create and launch a new thread of execution?()
A、 Run();
B、 Start();
C、 Execute();
D、 Run(Runnable r);
E、 Start(Runnable r);
F、 Execute(Thread t);
-
What is the result?()
A、 b,3
B、 b,8
C、 b,13
D、 f,3
E、 f,8
F、 f,13
G、 Compilation fails.
H、 An exception is thrown at runtime.
-
Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following: Which statement is true?()
A、 Compilation fails.
B、 Nothing is added to the file system.
C、 Only a new file is created on the file system.
D、 Only a new directory is created on the file system.
E、 Both a new file and a new directory are created on the file system.
-
Which statements about Java code security are true?()
AThe bytecode verifier loads all classes needed for the execution of a program.
BExecuting code is performed by the runtime interpreter.
CAt runtime the bytecodes are loaded, checked and run in an interpreter.
DThe class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources.