boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()  A、 aB、 bC、 cD、 dE、 Compilation fails.

题目

boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()  

  • A、 a
  • B、 b
  • C、 c
  • D、 d
  • E、 Compilation fails.

相似考题
更多“boolean bool = ”相关问题
  • 第1题:

    boolean a=false;boolean b=true;boolean c=(a&&b)&&(!b);boolean result=(a&am

    boolean a=false; boolean b=true; boolean c=(a&&b)&&(!b); boolean result=(a&b)&(!b); 执行完后,正确的结果是( )。

    A.c=false;result=false

    B.c=true,result=true

    C.c=true;result=false

    D.c=false;result=true


    正确答案:A
    解析:本题考查Java中的运算。首先要清楚,“&&”是逻辑与运算符;“!”是逻辑非运算符;“&”是按位与运算符。按照逻辑运算符“a&&b”是false,“!b”是false,所以c是false。“a及b”是false,所以result是false。要注意区分“&&”和“&”,以及运算符之间的优先级关系,本题虽然没有涉及,但也要作为重点掌握。

  • 第2题:

    下列布尔变量定义中,正确并且规范的是

    A.BOOLEAN canceled=false;

    B.boolean canceled=false;

    C.boolean CANCELED=false;

    D.boolean canceled=FALSE;


    正确答案:B
    解析:本题考查Java的简单数据类型的变量定义及Java的命名约定。Java中的命名规则中包含如下几条:
      (1)变量名、方法名首单词小写,其余单词只有首字母大写;
      (2)常量完全大写;
      (3)变量命名采用完整的英文描述符,第一个字母小写,任何中间单词的首字母大写。
      Java语言区分大小写。简单数据类型布尔型用boolean表示。布尔型数据只有两个值: true(真)和false(假)。
      经过上述分析可知,选项B和选项C都能正确的定义一个布尔型变量,但是选项C的变量名CANCELED不符合Java中的命名规则,而选项B的变量名符合变量名的命名规则。因此,选项B是符合规范的布尔变量定义语句。
      本题的正确答案是选项B。

  • 第3题:

    下面均为Java关键字的一组是()

    A、boolean,byte,long,true

    B、byte, long,true,goto

    C、goto ,Boolean,byte,true

    D、bool, long,true,auto


    答案:A

  • 第4题:

    在C#中下列表达式不正确的是()。

    • A、double a,double b=2,int c=3,a=b+c
    • B、short a,byte b=2,byte c=3,a=b+c
    • C、string a,string b=”1” string c=”2” a=b+c
    • D、bool a,bool b=true,bool c=false a=b==c

    正确答案:A

  • 第5题:

    假设变量$x=5,则表达式“$x<>4”的返回值类型是()。

    • A、bool(false)
    • B、bool(true)
    • C、int(1)
    • D、int(0)

    正确答案:B

  • 第6题:

    将有三个boolean值的数组初始化为true的是()

    • A、boolean[]b=newboolean[3]
    • B、"boolean[]b={true,true,true}"
    • C、"boolean[3]b={true,true,true}"
    • D、"boolean[]b=newboolean[3];b={true,true,true}"

    正确答案:B

  • 第7题:

    Which determines if “prefs” is a directory and exists on the file system?()  

    • A、 Boolean exists=Directory.exists (“prefs”);
    • B、 Boolean exists=(new File(“prefs”)).isDir();
    • C、 Boolean exists=(new Directory(“prefs”)).exists();
    • D、 Boolean exists=(new File(“prefs”)).isDirectory();
    • E、 Boolean exists=true;  Try{  Directory d = new Directory(“prefs”);  } catch (FileNotFoundException e) {  exists = false;  }

    正确答案:D

  • 第8题:

    You need to write a multicast delegate that accepts a DateTime argument.Which code segment should you use?()

    • A、public delegate int PowerDeviceOn(bool result,DateTime autoPowerOff);
    • B、public delegate bool PowerDeviceOn(object sender,EventArgs autoPowerOff);
    • C、public delegate void PowerDeviceOn(DateTime autoPowerOff);
    • D、public delegate bool PowerDeviceOn(DateTime autoPowerOff);

    正确答案:C

  • 第9题:

    单选题
    在public HttpSession getSession(boolean bool)的方法定义中,当bool为false时表明()
    A

    直接返回会话对象

    B

    当服务器已经创建了会话对象就返回该对象,否则返回null

    C

    直接返回null

    D

    当服务器已经创建了会话对象就返回该对象,否则新建一个会话对象并返回


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

  • 第10题:

    单选题
    Which determines if “prefs” is a directory and exists on the file system?()
    A

     Boolean exists=Directory.exists (“prefs”);

    B

     Boolean exists=(new File(“prefs”)).isDir();

    C

     Boolean exists=(new Directory(“prefs”)).exists();

    D

     Boolean exists=(new File(“prefs”)).isDirectory();

    E

     Boolean exists=true;  Try{  Directory d = new Directory(“prefs”);  } catch (FileNotFoundException e) {  exists = false;  }


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

  • 第11题:

    多选题
    A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()
    A

    public void setEnabled( boolean enabled) public boolean getEnabled()

    B

    public void setEnabled( boolean enabled) public void isEnabled()

    C

    public void setEnabled( boolean enabled) public boolean isEnabled()

    D

    public boolean setEnabled( boolean enabled) public boolean getEnabled()


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

  • 第12题:

    单选题
    您需要编写可接受日期时间参数并返回一个布尔值,多路广播的委托。您应该使用哪个代码段?()
    A

    public delegate int PowerDeviceOn(bool, DateTime);

    B

    public delegate bool PowerDeviceOn(Object, EventArgs);

    C

    public delegate void PowerDeviceOn(DateTime);

    D

    public delegate bool PowerDeviceOn(DateTime);


    正确答案: D
    解析: delegate关键字用于声明一个引用类型,该引用类型可用于封装命名方法或匿名方法。委托类似于C++中的函数指针;但是,委托是类型安全和可靠的。

  • 第13题:

    下面程序段: boolean a=false; boolean b=true; boolean c=(a||b)&&(b); boolean result=(a|b)&(b); 执行完后,正确的结果是

    A.c=false;result=false

    B.c=true,result=true

    C.c=true;result=false

    D.c=false;result=true


    正确答案:B
    解析:本题考查Java中的运算符。考试重点内容,历次考试都有题目涉及。首先要清楚,“&&”是逻辑与运算符;“&”是按位与运算符;“||”是逻辑或运算符;“|”是按位或运算符。“a||b”的结果为true,所以“true&&true”结果为true。而“a|b”的结果也为true,故result=(a|b)&(b)语句的结果也为true,选项B正确。

  • 第14题:

    下列关于boolean类型的叙述中,正确的是( )。A.可以将boolean类型的数值转换为int类型的数值SX

    下列关于boolean类型的叙述中,正确的是( )。

    A.可以将boolean类型的数值转换为int类型的数值

    B.可以将boolean类型的数值转换为字符串

    C.可以将boolean类型的数值转换为char类型的数值

    D.不能将boolean类型的数值转换为其他基本数据类型


    正确答案:D
    由于基本数据类型中boolean类型不是数字型,所以基本数据类型的转换是除了boolean类型以外的其他7种类型之间的转换。

  • 第15题:

    在public HttpSession getSession(boolean bool)的方法定义中,当bool为false时表明()

    • A、直接返回会话对象
    • B、当服务器已经创建了会话对象就返回该对象,否则返回null
    • C、直接返回null
    • D、当服务器已经创建了会话对象就返回该对象,否则新建一个会话对象并返回

    正确答案:B

  • 第16题:

    下面均为java关键字的一组是()

    • A、boolean ,byte,long,assert
    • B、byte,long,true,goto
    • C、goto,boolean,byte,null
    • D、boolean,long,false,auto

    正确答案:A

  • 第17题:

    假设变量bool_x是一个布尔型(逻辑型)的变量,则下面正确的赋值语句是()

    • A、bool_x="False"
    • B、bool_x=.FalsE.
    • C、bool_x=#False#
    • D、bool_x=False

    正确答案:D

  • 第18题:

    Which is a method of the MouseMotionListener interface?()

    • A、 Public void mouseMoved(MouseEvent)
    • B、 Public boolean mouseMoved(MouseEvent)
    • C、 Public void mouseMoved(MouseMotionEvent)
    • D、 Public boolean MouseMoved(MouseMotionEvent)
    • E、 Public boolean mouseMoved(MouseMotionEvent)

    正确答案:A

  • 第19题:

    You are creating an ASP.NET Web site. The site is configured to use Membership and Role management providers. You need to check whether the currently logged-on user is a member of a role namedAdministrators. Which code segment should you use?()

    • A、bool isMember = Roles.GetUsersInRole("Administrators").Any()
    • B、bool isMember = Membership.ValidateUser(User.Identity.Name, "Administrators")
    • C、bool isMember = Roles.GetRolesForUser("Administrators").Any()
    • D、bool isMember = User.IsInRole("Administrators")

    正确答案:D

  • 第20题:

    单选题
    如果已经定义了方法int f(bool b, int i),则以下方法中,哪一个不是合法的重载方法()。
    A

    double f(bool b, int i)

    B

    int f(double d, int i)

    C

    int f(bool b,int i, double d)

    D

    double f(bool d, int j)


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

  • 第21题:

    单选题
    boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()
    A

     a

    B

     b

    C

     c

    D

     d

    E

     Compilation fails.


    正确答案: E
    解析: First of all, the second println statement should print the character ‘b’ instead of ‘c’. Also, the answer is not E. but C. Indeed, the following line is perfectly legal: if ‘(bool = false)’. The bool variable will simply take the value of false and the IF statement will be evaluated to false. Therefore, the correct answer is C. 

  • 第22题:

    单选题
    Which is a method of the MouseMotionListener interface?()
    A

     Public void mouseMoved(MouseEvent)

    B

     Public boolean mouseMoved(MouseEvent)

    C

     Public void mouseMoved(MouseMotionEvent)

    D

     Public boolean MouseMoved(MouseMotionEvent)

    E

     Public boolean mouseMoved(MouseMotionEvent)


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

  • 第23题:

    单选题
    当需要将一个函数bool isnumber(char c)声明为内联函数时,则此内联函数的函数原型为(  )。
    A

    enum bool isnumber(char c);

    B

    define bool isnumber(char c);

    C

    inline bool isnumber(char c);

    D

    extern bool isnumber(char c);


    正确答案: A
    解析:
    函数原型应指出函数名、返回值类型以及在调用函数时必须提供的参数的个数和类型。要声明内联函数时,在函数声明或定义前加 inline 修饰符。