zoukankan      html  css  js  c++  java
  • java牛客刷题2020年9月21日

    java牛客刷题2020年9月21日

    1. what is the result of the following code?

      enum AccountType
      {
          SAVING, FIXED, CURRENT;
          private AccountType()
          {
              System.out.println(“It is a account type”);
          }
      }
      class EnumOne
      {
          public static void main(String[]args)
          {
              System.out.println(AccountType.FIXED);
          }
      }
      

      ​ 正确答案: C 你的答案: B (错误)

      Compiles fine and output is prints”It is a account type”once followed by”FIXED”
      Compiles fine and output is prints”It is a account type”twice followed by”FIXED”
      Compiles fine and output is prints”It is a account type”thrice followed by”FIXED”
      Compiles fine and output is prints”It is a account type”four times followed by”FIXED”
      Compilation fails
      解释:
      答案:C
      枚举类有三个实例,故调用三次构造方法,打印三次It is a account type
      
    2. 关于AWT和Swing说法正确的是?

      正确答案: D 你的答案: C (错误)

      A Swing是AWT的子类
      B AWT在不同操作系统中显示相同的风格
      C AWT不支持事件类型,Swing支持事件模型
      D Swing在不同的操作系统中显示相同的风格
      解释:
      AWT,抽象窗口工具包,是Java提供的建立图形用户界面的工具集,可用于生成现代的、鼠标控制的图形应用接口,且无需修改,就可以在各种软硬件平台上运行。
      而swing是Java语言在编写图形用户界面方面的新技术,Swing采用模型-视图-控制设计范式,Swing可以使Java程序在同一个平台上运行时能够有不同外观以供用户选择。
      两者不同在于一个是初代工具集,一个是进化版的工具集,用户不会再满足于初始的功能,而是更加注重于附加价值,明显从这点上,Swing是比AWT要好很多。
      写法上,Swing的头文件引用包需要用到Javax,组件调用时也需要在AWT的基础上加上“J”。
      
    3. 下面哪几个函数 public void example(){....} 的重载函数?()

      正确答案: A D 你的答案: A B D (错误)

      public void example(int m){...}
      public int example(){..}
      public void example2(){..}
      public int example(int m,float f){...}
      解释:
      AD ,函数方法名必须相同,看参数列表即可,无关返回值。
      
    4. 常用的servlet包的名称是?

      正确答案: B D 你的答案: B D (正确)

      java.servlet
      javax.servlet
      servlet.http
      javax.servlet.http
      解释:
      JEE5.0中的Servlet相关的就下面这几个包:
      javax.servlet
      javax.servlet.jsp
      java.servlet.jsp.el
      java.servlet.jsp.tagext
      而最用得多的就是
      javax.servlet
      javax.servlet.http
      这两个包了.
      
  • 相关阅读:
    模板——二分法
    Trie Tree(静态数组写法,好写)
    欧拉路径 基础题 hiho第49周
    Fleury算法求欧拉路径 hiho第50周
    hdu 5266 pog loves szh III 在线lca+线段树区间优化
    hdu 5269 字典树
    hdu 5265 pog loves szh II
    poj 3678 2-sat(强连通)
    lca 在线,离线 poj 1330
    lca 在线算法 zoj 3195
  • 原文地址:https://www.cnblogs.com/chenyameng/p/13703654.html
Copyright © 2011-2022 走看看