Date、Calendar以及DateFormat类都位于java.util包中

题目

Date、Calendar以及DateFormat类都位于java.util包中


相似考题
参考答案和解析
正确答案:错误
更多“Date、Calendar以及DateFormat类都位于jav”相关问题
  • 第1题:

    DateFormatdf;15.Datedate=newDate();16.//insertcodehere17.Strings=df.format(date);Whichtwo,insertedindependentlyatline16,allowthecodetocompile?()

    A.df=newDateFormat();

    B.df=Date.getFormatter();

    C.df=date.getFormatter();

    D.df=date.getDateFormatter();

    E.df=DateFormat.getDateInstance();

    F.df=DateFormat.getInstance();


    参考答案:E, F

  • 第2题:

    继承是Java语言的-个重要机制,所有的Java类都继承自根类( )。

    A.Class

    B.Object

    C.String

    D.Date


    正确答案:B
    本题考查Java的继承机制。Class类封装了类和对象的属性特征,包含着解释Java类的信息;Object类处于Java类层次结构的最上层,是所有类的父类,也就是说,所有Java语言中的类都是直接或间接继承0bieet类得到的;String类是字符串类,用于构造字符串常量。Date类是日期类,提供了处理日期、时间的多种方法。

  • 第3题:

    继承是Java语言的一个重要机制,所有的Java类都继承自根类( )。

    A.Class

    B.Object

    C.String

    D.Date


    正确答案:B
    解析: 本题考查Java的继承机制。Class类封装了类和对象的属性特征,包含着解释Java类的信息。Object类处于 Java类层次结构的最—卜层,是所有类的父类。也就是说,所有Java语言中的类都是直接或间接继承Obieet类得到的。String类是字符串类,用于构造字符串常量。Date类是日期类,提供了处理日期、时间的多种方法。

  • 第4题:

    继承是Java语言的一个重要机制,所有的Java类都继承自根类( )。 A.ClassB.ObjectSXB

    继承是Java语言的一个重要机制,所有的Java类都继承自根类( )。

    A.Class

    B.Object

    C.String

    D.Date


    正确答案:B
    B。【解析】本题考查Java的继承机制。Class类封装了类和对象的属性特征,包含着解释Java类的信息;Objeet类处于Java类层次结构的最上层,是所有类的父类,也就是说,所有Java语言中的类都是直接或间接继承0biec类得到的;String类是字符串类,用于构造字符串常量。Date类是日期类,提供了处理日期、时间的多种方法。

  • 第5题:

    下列关于javA.util.Date类的描述中,错误的是?()

    A.无参的构造方法Date(),用来创建当前日期时间的Date对象

    B.在JDK的javA.util包中提供了一个Date类用于表示日期和时间

    C.推荐使用Date(int year,int month,int date)构造方法来创建Date对象

    D.接收一个long型参数date的构造方法Date(long date),用于创建指定时间的Date对象


    答案:C
    解析:Date(int year,int month,int date)构造方法已经过时,Date类中只有两个构造方法是建议使用的,一个是无参的构造方法Date(),用来创建当前日期时间的Date对象。另一个是接收一个long型参数date的构造方法Date(long date),用于创建指定时间的Date对象。

  • 第6题:

    用户随便输入一个日期(yyyy-MM-dd), 打印出这个日期所在月的每一天, 格式如下:

    日 一 二 三 四 五 六

    1 2 3 4 5 6

    提示:

    (1) 字符串 -->util.Date

    (2) Date -->Calendar

    (3) 修改日期 -->set

    (4) 记录用户输入的是哪一天 -->get

    (5) 判断星期几 -->get

    (6) 获取该月份的最大天数 -->calendar.getActualMaximum

    (7) 日期自增 -->add


    答案:
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.Scanner;
    public class TestCalendar {
    //public class test{
    public static void main(String[] args) {
    //创建扫描器
    Scanner sc = new Scanner(System.in);
    while (true){
    //提示用户输入
    System.out.println("请输入一个日期,格式为:2018-12-05,输入exit退出");
    //接受用户输入
    String temp = sc.nextLine();
    if(temp.equalsIgnoreCase("exit")){//判断两个字符串是否相等忽略大小写
    System.out.println("ByeBye");
    break;
    }
    //创建日期格式化对象
    //DateFormat日期格式化类
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    try {
    //string --> date
    Date date = format.parse(temp);//此处需添加异常
    //date --> Calendar
    //创建日历对象
    Calendar calendar = new GregorianCalendar();
    //设置日期为用户输入日期
    calendar.setTime(date);
    //打印日历抬头
    System.out.println("日\t一\t二\t三\t四\t五\t六");
    //记录用户输入的日
    int currentDate = calendar.get(Calendar.DATE);
    //修改日期为此月的第一天
    calendar.set(Calendar.DAY_OF_MONTH,1);
    //获取第一天是星期几
    int week = calendar.get(Calendar.DAY_OF_WEEK);//1-7
    //打印缩进
    for (int i = 1; i < week; i++) {
    System.out.print("\t");
    }
    //获取当月的最大天数
    int maxDate=calendar.getActualMaximum(calendar.DATE);
    //循环打印天数
    for (int i = 1; i <= maxDate; i++) {
    //如果是当天,打印一个*
    if(calendar.get(Calendar.DATE) == currentDate){
    System.out.print("*");
    }
    //打印该天
    System.out.print(i+"\t");
    //如果是周六,打印换行
    if(calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
    System.out.println();
    }
    //天数加一
    calendar.add(Calendar.DATE,1);
    }}
    catch (ParseException e) {
    e.printStackTrace();
    }
    System.out.println();
    }
    }
    }

  • 第7题:

    14. DateFormat df;  15. Date date = new Date();  16. //insert code here  17. String s = df.format( date);  Which two,inserted independently at line 16, allow the code to compile?()

    • A、 df= new DateFormat();
    • B、 df= Date.getFormatter();
    • C、 df= date.getFormatter();
    • D、 df= date.getDateFormatter();
    • E、df = DateFormat.getDateInstance();
    • F、 df= DateFormat.getInstance();

    正确答案:E,F

  • 第8题:

    Given a valid DateFormat object named df,and 16.Date d = new Date(0L); 17.String ds = "December 15, 2004"; 18.//insert code here What updates d’s value with the date represented by ds?()

    • A、18. d = df.parse(ds);
    • B、18. d = df.getDate(ds);
    • C、18. try {19. d = df.parse(ds);20. } catch(ParseException e) { };
    • D、18. try {19. d = df.getDate(ds);20. } catch(ParseException e) { };

    正确答案:C

  • 第9题:

    判断题
    Date、Calendar以及DateFormat类都位于java.util包中
    A

    B


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

  • 第10题:

    单选题
    You manage a department that uses Microsoft Windows Calendar to assign tasks. Another member of the department owns the calendar.  The calendar is published to a shared network location. Users report that they do not see the most recent updates to the assigned tasks.  You need to ensure that the shared calendar displays the latest updates.  What should you do? ()
    A

    Select the published calendar in Windows Calendar, and then click the Sync All option. 

    B

    Publish your local calendar in Windows Calendar and then click the Automatically publish changes option.

    C

    Schedule a task to publish the Calendar.ics file to the shared network location. Configure the task to run on an hourly schedule.

    D

    Instruct the calendar owner to click the Local calendar option in Windows Calendar, and then click the Automatically publish changes option for tasks.


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

  • 第11题:

    单选题
    Given: 12.Date date = new Date(); 13.df.setLocale(Locale.ITALY); 14.String s = df.format(date); The variable df is an object of type DateFormat that has been initialized in line 11. What is the result if this code is run on December 14, 2000?()
    A

    The value of s is 14-dic-2000.

    B

    The value of s is Dec 14, 2000.

    C

    An exception is thrown at runtime.

    D

    Compilation fails because of an error in line 13.


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

  • 第12题:

    单选题
    Given a valid DateFormat object named df,and 16.Date d = new Date(0L); 17.String ds = "December 15, 2004"; 18.//insert code here What updates d’s value with the date represented by ds?()
    A

    18. d = df.parse(ds);

    B

    18. d = df.getDate(ds);

    C

    18. try {19. d = df.parse(ds);20. } catch(ParseException e) { };

    D

    18. try {19. d = df.getDate(ds);20. } catch(ParseException e) { };


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

  • 第13题:

    Given:Which code fragment, inserted at line 23, allows the code to compile?()

    A.df = new DateFormat();

    B.df = Date.getFormat();

    C.df = date.getFormat();

    D.df = DateFormat.getFormat();

    E.df = DateFormat.getInstance();


    参考答案:E

  • 第14题:

    在下面附属类方法中的下划线处应填入的正确参数是( )。 public void writeData( ______ ) throws IOException{ GregorianCalendar calendar=new GregorianCalendar(); calendar.setTime(hireDay); out.println(name+"|"+salary+"|" +calendar.get(Calendar.YEAR)+"I" +(calendar.get(Calendar.MONTH)+1)+"|" +calendar.get(Calendar.DAY_OF_MONTH)); }

    A.Employee[]e

    B.employee.dat

    C.PrintWriter out

    D.BufferedWriter


    正确答案:C
    解析:本题考查考生对附属类的掌握。题目看起来很难,其实不用去理解程序即可回答,按照Java中的语法规则,只有选项C满足题目。在题目中出现了“out”变量,只有选项C中“PrintWriter out”有该变量。选项A只是用来定义一个数组,选项B是一个常量,不能用在这里,选项D中“BufferedWriter”后缺少参数。这个题目考点有些含糊,容易让考生莫名其妙,如果将程序整个给出也许更好一些,了解即可,本题的关键是明白附属类的概念。

  • 第15题:

    3在下面附属类方法中的下划线处应填入的正确参数是( )。 public void writeData(______)throws IOException { GregorianCalendar calendar=new GregorianCalendar(); calendar.setTime(hireDay); out.println(name+"T" +salary+"|" +calendar.get(Calendar.YEAR)+"|" +(calendar.get(Calendar.MONTH)+1)+ "|" +calandar.get(Calendar.DAY_OF_MONTH)); }

    A.Employee[] e

    B.employee.dat

    C.PrintWriter out

    D.BufferedWriter


    正确答案:C

  • 第16题:

    Calendar类中,用于为指定的日历字段增加或减去指定的时间量的方法是?()

    A.int get(int field)

    B.void add(int field,int amount)

    C.void set(int field,int value)

    D.void set(int year,int month,int date)


    答案:B

  • 第17题:

    下列关于Date类的描述中,错误的是?()

    A、Date类获取的时间是以1970秒开始计时的

    B、在JDK1.1之后,Date类逐渐被Calendar类取代

    C、Date类中大部分构造方法都被声明为已过时

    D、Date类中大部分方法依然推荐使用


    正确答案:D

  • 第18题:

    What is the name of the User Interface (UI) widget that is just a standard edit box that is linked to a calendar with the pop-up property set?()

    • A、Date-Time Picker
    • B、Calendar Picker
    • C、Date Picker
    • D、Date Selector

    正确答案:A

  • 第19题:

    Given: 12.Date date = new Date(); 13.df.setLocale(Locale.ITALY); 14.String s = df.format(date); The variable df is an object of type DateFormat that has been initialized in line 11. What is the result if this code is run on December 14, 2000?()

    • A、The value of s is 14-dic-2000.
    • B、The value of s is Dec 14, 2000.
    • C、An exception is thrown at runtime.
    • D、Compilation fails because of an error in line 13.

    正确答案:D

  • 第20题:

    多选题
    公司对于项目sales revenue booking的两个必要条件是什么?()
    A

    设备已从工厂发出

    B

    设备已存储在代理商仓库内

    C

    设备已存储在最终用户现场,或已安装在最终用户现场

    D

    设备安装场地完工(场地检查表无否项)时间在LCD(last calendar date)之内

    E

    设备安装场地完工(场地检查表无否项)时间在“LCD(last calendar date)+30天“之内


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

  • 第21题:

    多选题
    14. DateFormat df;  15. Date date = new Date();  16. //insert code here  17. String s = df.format( date);  Which two,inserted independently at line 16, allow the code to compile?()
    A

    df= new DateFormat();

    B

    df= Date.getFormatter();

    C

    df= date.getFormatter();

    D

    df= date.getDateFormatter();

    E

    df = DateFormat.getDateInstance();

    F

    df= DateFormat.getInstance();


    正确答案: E,F
    解析: 暂无解析

  • 第22题:

    单选题
    You are hosting a Windows Communication Foundation (WCF) service under Microsoft Interent Information Services (IIS) 7.0. You have set up a web site in IIS Manager. The physical path is c:/wwwroot/Calendar. There is a Calendar.svc file in the c:/wwwroot/Calendar folder. It contains the following directive: The CalendarSvc.cs file contains the source for the Calendar class in the Calendar namespace. You compile this code into the Calendar.dll file. You need to deploy your service to the web site. What should you do?()
    A

    Copy the Calendar.dll file to the c:/wwwroot/Calendar/code folder

    B

    Copy the Calendar.dll file to the c:/wwwroot/Calendar/bin folder

    C

    Copy the Calendar.svc.cs file to the c:/wwwroot/Calendar/bin folder

    D

    Copy the Calendar.svc.cs file to the c:/wwwroot/Calendar/code folder


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

  • 第23题:

    单选题
    33. Date d = new Date(0);  34. String ds = “December 15, 2004”;  35. // insert code here  36. try {  37. d = df.parse(ds);  38. }  39. catch(ParseException e) {  40. System.out.println(”Unable to parse “+ ds);  41. }  42. // insert code here too  Which will create the appropriate DateFormat object and add a day to the Date object?()
    A

     35. DateFormat df= DateFormat.getDateFormat(); 42. d.setTime( (60 * 60 * 24) +d.getTime());

    B

     35. DateFormat df= DateFormat.getDateJnstance(); 42. d.setTime( (1000 * 60 * 60 * 24) + d.getTime());

    C

     35. DateFormat df= DateFormat.getDateFormat(); 42. d.setLocalTime( (1000*60*60*24) + d.getLocalTime());

    D

     35. DateFormat df= DateFormat.getDateJnstance(); 42. d.setLocalTime( (60 * 60 * 24) + d.getLocalTime());


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