网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
public class X { public object m () { object o = new float (3.14F); object oa = new object [1]; oa[0]= o; o = null; oa[0] = null; return o; } } When is the float object created in line 3, eligible for garbage collection?()
A
Just after line 5.
B
Just after line 6.
C
Just after line 7.
D
Just after line 8(that is, as the method returns).
参考答案
参考解析
解析:
暂无解析
更多 “单选题public class X { public object m () { object o = new float (3.14F); object oa = new object [1]; oa[0]= o; o = null; oa[0] = null; return o; } } When is the float object created in line 3, eligible for garbage collection?()A Just after line 5.B Just after line 6.C Just after line 7.D Just after line 8(that is, as the method returns).” 相关考题
考题
阅读下列函数说明和Java代码,将应填入(n)处的字句写在对应栏内。【说明】类Queue表示队列,类中的方法如下表所示。类Node表示队列中的元素;类EmptyQueueException给出了队列操作中的异常处理操作。public class TestMain { //主类public static viod main (String args[]){Queue q=new Queue();q.enqueue("first!");q.enqueue("second!");q.enqueue("third!");(1) {while(true)System.out.println(q.dequeue());}catch( (2) ){ }}public class Queue { //队列Node m_FirstNode;public Queue(){m_FirstNode=null;}public boolean isEmpty(){if(m_FirstNode==null)return true;else return false;}public viod enqueue(Object newNode) { //入队操作Node next=m_FirstNode;if(next==null)m_FirstNode=new Node(newNode);else{while(next.getNext()!=null)next=next.getNext();next.setNext(new node(newNode));}}public Object dequeue() (3) { //出队操作Object node;if (isEempty())(4); //队列为空, 抛出异常else{node=m_FirstNode.getObject();m_FirstNode=m_FirstNode.getNext();return node;}}}public class Node{ //队列中的元素Object m_Data;Node m_Next;public Node(Object data) {m_Data=data; m_Next=null;}public Node(Object data, Node next) {m_Data=data; m_Next=-next;}public void setObject(Object data) {m_Data=data;}public Object getObject(Object data) {return m_data;}public void setNext(Node next) {m_Next=next;}public Node getNext() {return m_Next;}}public class EmptyQueueException extends (5) { //异常处理类public EmptyQueueException() {System.out.println("队列已空! ");}}
考题
1.public class GC{2.private Objec to;3.private void doSomethingElse(Object obj){o=obj;}4.public void doSomething(){5.Object o=new Object();6.doSomethingElse(o);7.o=new Object();8.doSomethingElse(null);9.o=null;10.}11.}When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()A.Line5B.Line6C.Line7D.Line8E.Line9F.Line10
考题
Given:Which two, inserted at line 11, will allow the code to compile?()
A.public class MinMax? {B.public class MinMax? extends Number {C.public class MinMaxN extends Object {D.public class MinMaxN extends Number {E.public class MinMax? extends Object {F.public class MinMaxN extends Integer {
考题
Given:Which method will complete this class?()
A.public int compareTo(Object o){/*more code here*/}B.public int compareTo(Score other){/*more code here*/}C.public int compare(Score s1,Score s2){/*more code here*/}D.public int compare(Object o1,Object o2){/*more code here*/}
考题
阅读以下说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。说明类Queue表示队列,类中的方法如下表所示。类Node表示队列中的元素;类EmptyQueueException 给出了队列操作中的异常处理操作。Java 代码public class TestMain{ // 主类public static void main(String args[]) {Queue q = new Queue();q.enqueue("first!");q.enqueue("second!");q.enqueue("third!");(1) {while(true)System.out.println(q. dequeue());}catch((2)) ( }}}public class Queue { // 队列Node m_FirstNode;public Queue() { m_FirstNode = null; }public boolean isEmpty() {if(m_FirstNode == null) return true;else return false;}public void enqueue(Object newNode) {// 入队操作Node next = m_FirstNode;if(next==null) m_FirstNode = new Node(newNode);else {while(next.getNext() != null) next = next.getNext();next.setNext(new Node(newNode));}}public Object dequeue() (3) {// 出队操作Object node;if (isEmpty())(4); // 队列为空,抛出异常else {node = m_FirstNode.getObject();m_FirstNode = m_FirstNode.getNext();return node;}}}public class Node { // 队列中的元素Object m_Data;Node m_Next;public Node(Object data) { m_Data = data; m_Next = null; }public Node(Object data, Node next) { m_Data = data; m_Next = next; }public void setObject(Object data) { m_Data = data; }public Object getObject0 { return m_Data; }public void setNext(Node next) { m_Next = next; }public Node getNext() { return m_Next; }}public class EmptyQueueException extends (5) { // 异常处理类public EmptyQueueException0 {System.out.println("队列已空 ! ");}}
考题
public class X { public object m () { object o = new float (3.14F); object oa = new object [1]; oa[0]= o; o = null; return oa[0]; } } When is the float object created in line 3, eligible for garbage collection?()A、 Just after line 5B、 Just after line 6C、 Just after line 7 (that is, as the method returns)D、 Never in this method.
考题
1.public class GC{ 2.private Objec to; 3.private void doSomethingElse(Object obj){o=obj;} 4.public void doSomething(){ 5.Object o=new Object(); 6.doSomethingElse(o); 7.o=new Object(); 8.doSomethingElse(null); 9.o=null; 10.} 11.} When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()A、Line5B、Line6C、Line7D、Line8E、Line9F、Line10
考题
下列代码正确的是哪项?() A、 public class Session implements Runnable, Clonable{ public void run ();public Object clone () ; }B、 public class Session extends Runnable, Cloneable { public void run() {/*dosomething*/} public Object clone() {/*make a copy*/} }C、 public abstract class Session implements Runnable, Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }D、 public class Session implements Runnable, implements Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
考题
1. public class X ( 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. return oa[0]; 8. } 9. } When is the float object created in line 3, eligible for garbage collection?() A、 Just after line 5B、 Just after line 6C、 Just after line 7 (that is, as the method returns)D、 Never in this method.
考题
package geometry; public class Hypotenuse { public InnerTriangle it = new InnerTriangle(); class InnerTriangle { public int base; public int height; } } Which is true about the class of an object that can reference the variable base? ()A、 It can be any class.B、 No class has access to base.C、 The class must belong to the geometry package.D、 The class must be a subclass of the class Hypotenuse.
考题
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 X { 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. oa[0] = null; 10. return o; 9. } 10. } When is the float object created in line 3, eligible for garbage collection?() A、 Just after line 5.B、 Just after line 6.C、 Just after line 7.D、 Just after line 8(that is, as the method returns).
考题
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.
考题
public class Key { private long id1; private long 1d2; // class Key methods } A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()A、 public int hashCode()B、 public boolean equals(Key k)C、 public int compareTo(Object o)D、 public boolean equals(Object o)E、 public boolean compareTo(Key k)
考题
public class X { public object m () { object o = new float (3.14F); object oa = new object [1]; oa[0]= o; o = null; oa[0] = null; return o; } } When is the float object created in line 3, eligible for garbage collection?() A、 Just after line 5.B、 Just after line 6.C、 Just after line 7.D、 Just after line 8(that is, as the method returns).
考题
Which three will compile and run without exception?()A、private synchronized Object o;B、void go() {synchronized() { /* code here */ }C、public synchronized void go() { /* code here */ }D、private synchronized(this) void go() { /* code here */ }E、void go() {synchronized(Object.class) { /* code here */ }F、void go() {Object o = new Object();synchronized(o) { /* code here */ }
考题
单选题1. public class X { 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. oa[0] = null; 10. return o; 9. } 10. } When is the float object created in line 3, eligible for garbage collection?()A
Just after line 5.B
Just after line 6.C
Just after line 7.D
Just after line 8(that is, as the method returns).
考题
单选题1.public class GC{ 2.private Objec to; 3.private void doSomethingElse(Object obj){o=obj;} 4.public void doSomething(){ 5.Object o=new Object(); 6.doSomethingElse(o); 7.o=new Object(); 8.doSomethingElse(null); 9.o=null; 10.} 11.} When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()A
Line5B
Line6C
Line7D
Line8E
Line9F
Line10
考题
单选题public class Drink implements Comparable { public String name; public int compareTo(Object o) { return 0; } } and: Drink one = new Drink(); Drink two = new Drink(); one.name= “Coffee”; two.name= “Tea”; TreeSet set = new TreeSet(); set.add(one); set.add(two); A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()A
TeaB
CoffeeC
Coffee TeaD
Compilation fails.E
The code runs with no output.F
An exception is thrown at runtime.
考题
单选题下列代码正确的是哪项?()A
public class Session implements Runnable, Clonable{ public void run ();public Object clone () ; }B
public class Session extends Runnable, Cloneable { public void run() {/*dosomething*/} public Object clone() {/*make a copy*/} }C
public abstract class Session implements Runnable, Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }D
public class Session implements Runnable, implements Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
考题
单选题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.
考题
单选题package geometry; public class Hypotenuse { public InnerTriangle it = new InnerTriangle(); class InnerTriangle { public int base; public int height; } } Which is true about the class of an object that can reference the variable base? ()A
It can be any class.B
No class has access to base.C
The class must belong to the geometry package.D
The class must be a subclass of the class Hypotenuse.
考题
单选题1. public class X ( 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. return oa[0]; 8. } 9. } When is the float object created in line 3, eligible for garbage collection?()A
Just after line 5B
Just after line 6C
Just after line 7 (that is, as the method returns)D
Never in this method.
考题
单选题public class X { public object m () { object o = new float (3.14F); object oa = new object [1]; oa[0]= o; o = null; return oa[0]; } } When is the float object created in line 3, eligible for garbage collection?()A
Just after line 5B
Just after line 6C
Just after line 7 (that is, as the method returns)D
Never in this method.
考题
单选题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 GC { 2. private Object o; 3. private void doSomethingElse(Object obj) { o = obj; } 4. public void doSomething() { 5. Object o = new Object(); 6. doSomethingElse(o); 7. o = new Object(); 8. doSomethingElse(null); 9.o=null; 10. } 11. } When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()A
Line 5B
Line 6C
Line 7D
Line 8E
Line 9F
Line 10
考题
单选题public class Score implements Comparable { private int wins, losses; public Score(int w, int 1) { wins = w; losses = 1; } public int getWins() { return wins; } public int getLosses() { return losses; } public String toString() { return “”; } // insert code here } Which method will complete this class?()A
public int compareTo(Object o) {/*mode code here*/}B
public int compareTo(Score other) {/*more code here*/}C
public int compare(Score s1,Score s2){/*more code here*/}D
public int compare(Object o1,Object o2){/*more code here*/}
热门标签
最新试卷