( 难度:中等)[typeof null, null instanceof Object]这些类型的结果是( )A.["object", false]B.[null, false]C.["object", true]D.other

题目
( 难度:中等)[typeof null, null instanceof Object]这些类型的结果是( )
A.["object", false]
B.[null, false]
C.["object", true]
D.other

相似考题

1.阅读下列函数说明和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("队列已空! ");}}

4.阅读以下技术说明和Java代码,将Java程序中(1)~(5)空缺处的语句填写完整。[说明]类Queue表示队列,类中的方法如表4-12所示。类Node表示队列中的元素;类EmptyQueueException给出了队列中的异常处理操作。[Java代码]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;elsereturn 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 (is empty())(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 ( "队列已空!" );}}

更多“( 难度:中等)[typeof null, null instanceof Object]这些类型的结果是( )A.["object", false]B.[null, false]C.["object", true]D.other”相关问题
  • 第1题:

    请选择结果为真的表达式:( )

    A. typeof null !="object"

    B. null === undefined

    C. 1 == " 01.00"

    D. NaN == NaN


    正确答案:C

  • 第2题:

    What allows the programmer to destroy an object x?()  

    • A、 x.delete()
    • B、 x.finalize()
    • C、 Runtime.getRuntime().gc()
    • D、 Explicitly setting the object’s reference to null.
    • E、 Ensuring there are no references to the object.
    • F、 Only the garbage collection system can destroy an object.

    正确答案:F

  • 第3题:

    You are building a Front Controller using a JSP page and you need to determine if the user’s session hasNOT been created yet and perform some special processing for this case. Which scriptlet code snippet willperform this test?()

    • A、<% if ( request.getSession(false) == null ) {// special processing} %>
    • B、<% if ( request.getHttpSession(false) == null ) {// special processing} %>
    • C、<% if ( requestObject.getSession(false) == null ) { // special processing} %>
    • D、<% if ( requestObject.getHttpSession(false) == null ) { // special processing} %>

    正确答案:A

  • 第4题:

    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).

    正确答案:C

  • 第5题:

    var one;var two=null;console.log(one==two,one===two);上面代码的输出结果是()。

    • A、false true
    • B、true false
    • C、false false
    • D、true true

    正确答案:B

  • 第6题:

    单选题
    Given a method that must ensure that its parameter is not null: 11. public void someMethod(Object value) { 12. // check for null value ... 20. System.out.println(value.getClass()); 21. } What inserted at line 12, is the appropriate way to handle a null value?()
    A

    assert value == null;

    B

    assert value != null, value is null;

    C

    if (value == null) { throw new AssertionException(value is null); }

    D

    if (value == null) { throw new IllegalArgumentException(value is null); }


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

  • 第7题:

    单选题
    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).


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

  • 第8题:

    单选题
    Given a method that must ensure that its parameter is not null: 11. public void someMethod(Object value) { 12. // check for null value ... 20. System.out.println(value.getClass()); 21. } What inserted at line 12, is the appropriate way to handle a null value?()
    A

    assert value == null;

    B

    assert value != null, value is null;

    C

    if (value == null) { throw new AssertionException(value is null); }

    D

    if (value == null) { throw new IllegalArgumentException(value is null); }


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

  • 第9题:

    单选题
    Given a method that must ensure that its parameter is not null: 11. public void someMethod(Object value) { 12. // check for null value ... 20. System.out.println(value.getClass()); 21. } What inserted at line 12, is the appropriate way to handle a null value?()
    A

    assert value == null;

    B

    assert value != null, value is null;

    C

    if (value == null) { throw new AssertionException(value is null); }

    D

    if (value == null) { throw new IllegalArgumentException(value is null); }


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

  • 第10题:

    单选题
    11. public void someMethod(Object value) {  12. // check for null value ....  20. System.out.println(value.getClass());  21. }  What, inserted at line 12, is the appropriate way to handle a null value?()
    A

     assert value == null;

    B

     assert value !null, “value is null”;

    C

     if (value == null) { throw new AssertionException(”value is null”);

    D

     if (value == null) { throw new IllegalArgumentException(”value is null”);


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

  • 第11题:

    单选题
    11. public void someMethod(Object value) {  12. // check for null value ....  20. System.out.println(value.getClass());  21. }  What, inserted at line 12, is the appropriate way to handle a null value?()
    A

     assert value == null;

    B

     assert value !null, “value is null”;

    C

     if (value == null) { throw new AssertionException(”value is null”);

    D

     if (value == null) { throw new IllegalArgumentException(”value is null”);


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

  • 第12题:

    单选题
    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).


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

  • 第13题:

    阅读以下说明和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("队列已空 ! ");

    }

    }


    正确答案:(1)try (2)EmptyQueueException e (3)throws EmpbtyQUeUeExCeption (4)throw(new EmptyQueueException()) (5)Exception
    (1)try (2)EmptyQueueException e (3)throws EmpbtyQUeUeExCeption (4)throw(new EmptyQueueException()) (5)Exception 解析:本题以队列为例,考查Java的异常处理机制。
    异常是指程序执行期间中断指令的正常流程的事件。当一个方法中发生错误时,此方法创建一个对象并将它交给运行时系统,此对象被称为异常对象。它包含关于错误的信息,包括错误的类型和错误发生时程序的状态。创建异常对象并将它交给运行时系统被称为抛出二个异常。
    (Java运行时系统要求方法必须捕获或者指定它可以抛出的所有被检查的异常。)
    ▲捕获。方法可以通过为某类型的异常提供异常处理器来捕获异常。
    ▲指定。方法通过在它的声明块中使用throws子句(throws异常类型)指定它可以抛出异常。
    ▲被检查的异常。存在两种异常:运行时异常和非运行时异常。运行时异常在Java运行时系统内发生,如算术异常、指针异常等。方法不必捕获或指定运行时异常。非运行时异常是在Java运行时系统外的代码中发生的异常。编译器确保非运行时异常被捕获或指定,因此它们也被称为“被检查的异常”。
    ▲方法可以抛出的异常。包括:方法用throw语句直接抛出的任何异常;通过调用另一个方法间接抛出的任何异常。
    try块和catch块是异常处理器的两个组件。在try块中产生的异常通常被紧跟其后的catch块指定的处理器捕获:
    try{
    可能抛出异常的语句
    }
    catch(异常类型异常引用){
    处理异常的语句
    }
    在选择要抛出的异常的类型时,可以使用其他人编写的异常类,也可以编写自己的异常类。本题中采用自定义的类作为异常的类型。
    本题中主类TestMain包含了异常处理机制,用于检测在出队时“队列为空”的错误。根据上面的描述,很容易得出第(1)空应填try。第(2)空应填写对相应异常类型的引用。由程序的注释可以得到,类EmptyQueueException是进行异常处理的类,因此第(2)空应填EmptyQueueException e(e为引用名)。由于异常都是从超类Exception派生而来的,因此第(5)空应填Exception。
    由主类TestMain可以看到,在try块的内部并没有给出显示的抛出异常语句,即没有出现throw语句。由此可以得出,在类Queue的方法dequeue中必定要抛出异常。因此首先应指定方法dequeue可以抛出异常,则第(3)空应填throws EmptyQueueException。
    由dequeue方法的注释可以看出,第(4)空应该是使用throw语句抛出异常。throw语
    句需要—个参数:—个可抛出的对象。因此第(4)空应填throw(newEmptyQueueException())。

  • 第14题:

    请选择结果为真的表达式:()。

    • A、typeof null !="object"
    • B、null == undefined
    • C、1 == "01.00"
    • D、NaN == NaN

    正确答案:C

  • 第15题:

    11. public void someMethod(Object value) {  12. // check for null value ....  20. System.out.println(value.getClass());  21. }  What, inserted at line 12, is the appropriate way to handle a null value?() 

    • A、 assert value == null;
    • B、 assert value !null, “value is null”;
    • C、 if (value == null) { throw new AssertionException(”value is null”);
    • D、 if (value == null) { throw new IllegalArgumentException(”value is null”);

    正确答案:D

  • 第16题:

    Given a method that must ensure that its parameter is not null: 11. public void someMethod(Object value) { 12. // check for null value ... 20. System.out.println(value.getClass()); 21. } What inserted at line 12, is the appropriate way to handle a null value?()

    • A、assert value == null;
    • B、assert value != null, "value is null";
    • C、if (value == null) { throw new AssertionException("value is null"); }
    • D、if (value == null) { throw new IllegalArgumentException("value is null"); }

    正确答案:D

  • 第17题:

    单选题
    Given a method that must ensure that its parameter is not null: 11. public void someMethod(Object value) { 12. // check for null value ... 20. System.out.println(value.getClass()); 21. } What inserted at line 12, is the appropriate way to handle a null value?()
    A

    assert value == null;

    B

    assert value != null, value is null;

    C

    if (value == null) { throw new AssertionException(value is null); }

    D

    if (value == null) { throw new IllegalArgumentException(value is null); }


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

  • 第18题:

    单选题
    You are building a Front Controller using a JSP page and you need to determine if the user’s session hasNOT been created yet and perform some special processing for this case. Which scriptlet code snippet willperform this test?()
    A

    <% if ( request.getSession(false) == null ) {// special processing} %>

    B

    <% if ( request.getHttpSession(false) == null ) {// special processing} %>

    C

    <% if ( requestObject.getSession(false) == null ) { // special processing} %>

    D

    <% if ( requestObject.getHttpSession(false) == null ) { // special processing} %>


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

  • 第19题:

    单选题
    You are building a Front Controller using a JSP page and you need to determine if the user’s session hasNOT been created yet and perform some special processing for this case. Which scriptlet code snippet willperform this test?()
    A

    <% if ( request.getSession(false) == null ) {// special processing} %>

    B

    <% if ( request.getHttpSession(false) == null ) {// special processing} %>

    C

    <% if ( requestObject.getSession(false) == null ) { // special processing} %>

    D

    <% if ( requestObject.getHttpSession(false) == null ) { // special processing} %>


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

  • 第20题:

    单选题
    11. public void someMethod(Object value) {  12. // check for null value ....  20. System.out.println(value.getClass());  21. }  What, inserted at line 12, is the appropriate way to handle a null value?()
    A

     assert value == null;

    B

     assert value !null, “value is null”;

    C

     if (value == null) { throw new AssertionException(”value is null”);

    D

     if (value == null) { throw new IllegalArgumentException(”value is null”);


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

  • 第21题:

    单选题
    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).


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

  • 第22题:

    单选题
    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).


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

  • 第23题:

    单选题
    You are building a Front Controller using a JSP page and you need to determine if the user’s session hasNOT been created yet and perform some special processing for this case. Which scriptlet code snippet willperform this test?()
    A

    <% if ( request.getSession(false) == null ) {// special processing} %>

    B

    <% if ( request.getHttpSession(false) == null ) {// special processing} %>

    C

    <% if ( requestObject.getSession(false) == null ) { // special processing} %>

    D

    <% if ( requestObject.getHttpSession(false) == null ) { // special processing} %>


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

  • 第24题:

    ( 难度:中等)请选择结果为真的表达式:()
    A.null instanceof Object
    B.null === undefined
    C.null == undefined
    D.NaN == NaN

    答案:C