1PTA预习:Java语言基础
创始人
2024-04-26 10:26:30
0

第一题:判断题

  1. Compiled Java program can be executed in any operating systems directly.【T】
  2. 在一个编辑器中编写好的Java应用程序,是扩展名为.class的文件。【F】
  3. java语言中不用区分字母的大写小写。【F】
  4. Java的字符类型采用的是ASCII编码。【F】
  5. Java的字符类型采用的是Unicode编码,每个Unicode码占16个比特。【T】
  6. Java的各种数据类型占用固定长度,与具体的软硬件平台环境无关。【T】
  7. Java语言中,变量名可以用汉字表示。【T】
  8. 字节码文件是与平台无关的二进制码,执行时由解释器解释成本地机器码。【T】
  9. 一个Java源文件中可以有多个类,但只能有一个类是public的。【T】
  10. 如果Java源文件中包含了多个类,那么用编译器javac编译完源文件后将生成多个扩展名为.class的文件。 【T】
  11. 语句 System.out.println(4+8+“Hello,world!”); 的输出结果是12Hello,world!。【T】
  12. boolean done = true; is a valid assignment
    statement.,【T】
  13. The following answers is the correct way
    to declare a Boolean variable named truth:
    boolean truth == true;【F】
  14. char of Java is 8-bit.【F】
  15. boolean型数据的值只有true和false。【T】

第二题:选择题

  1. About JIT JVM, which statement below is correct?【B】
    A.The compiler generates native code, so JIT runs faster.
    B.The JVM will translate byte code into native code at class loading.
    C.The JVM will compile source code into native code at class loading.
    D.Only JNI code runs faster in JIT JVM.

  2. About JIT JVM, which statement below is correct?【C】
    A.The compiler generates native code for JIT JVM.
    B.There is a special translator to convert byte code into native code before its loading into the JVM.
    C.It is the JVM that translates the byte code into native during the loading of the class.
    D.Java Native Invoking is the way JIT JVM does to make program run faster.

  3. Which statements about the garbage collection are true?【B】
    A.The program developer must create a thread to be responsible for free the memory.
    B.The garbage collection will check for and free memory no longer needed.
    C.The garbage collection allows the program developer to explicitly and immediately free the memory.
    D.The garbage collection can free the memory used by Java object at expect time.

  4. 选项()不是Java语言的特点。【D】
    A.面向对象
    B.可移植
    C.解释型
    D.可访问物理内存

  5. 关于Java语言的描述,错误的是()。【A】
    A.每一个.java文件编译后对应一个.class文件。
    B. .java文件编译后,每一个class对应一个.class文件
    C.Java源代码编译后产生的.class是字节码文件
    D. .class文件在JVM上运行

  6. 在windows平台上安装配置JDK时,下列的说法错误的是_____。【C】
    A.设置path的作用是指定命令搜索路径
    B.设置CLASSPATH的作用是指定类搜索路径
    C.javac的功能是编译并执行 java代码项
    D.假设JDK的安装位置是:c:\java,那么应在path中加入下面的数据项:c:\java\bin

  7. 一个计算机上安装JDK后,该计算机不包含的是()。【C】
    A.JRE
    B.JVM
    C.Eclipse
    D.javac.exe

  8. 整型数据类型中,需要内存空间最少的是( ).【D】
    A.short
    B.long
    C.int
    D.byte

  9. Which statement below is correct?【A】
    A.int is always 32-bit on different platforms
    B.int is 32-bit on 32-bit and smaller platforms, but 64-bit on 64-bit machines
    C.int varies from platform to platform
    D.int is always 64-bit on different platforms

  10. Which statement below is incorrect:【A】
    A.float a = 2.0
    B.double b=2.0
    C.int c=2
    D.long d=2

  11. Which word below is NOT keyword of Java? ( )【B】
    A.const
    B.NULL
    C.false
    D.native

  12. Which line below will not generate warning or error when compiling? ( )【D】
    A.float f = 1.3;
    B.char c = “a”;
    C.byte b = 257;
    D.int i = 10;

  13. Which is the value of temp after the code’s execution? ( )【B】
    long temp = (int)3.9;
    temp %= 2;
    A.0
    B.1
    C.2
    D.3

  14. About Java, which statement below is NOT correct?【A】
    A.The size of int type varies from platform to platform.
    B.The size of int type is always 4 bytes among all the platforms.
    C.The size of char type is Unicode coded.
    D.A value of char type can be transformed to a value of int.

  15. About the Java language, which statement below is NOT correct?【C】
    A.A variable of byte type occupies one byte
    B.A class can implement more than one interface
    C.A class can inherit from more than one super class
    D.All arrays are to be created dynamically.

  16. About Java, which statement below is NOT correct?【C】
    A.Big-endian is used to store all multi-byte data types.
    B.The size of int type is always 4 bytes among all the platforms.
    C.The char type is UTF-8 coded.
    D.A value of char type can be transformed to a value of int.

  17. Given:
    Integer.valueOf(1).equals(Long.valueOf(1))
    which statement below is right?【C】
    A.It doesn’t compile.
    B.The value is true.
    C.The value is false.
    D.It throws exception in run-time.

  18. 对下列代码执行结果的描述,错误的是()。【A】
    A.int x=3,y=5; System.out.println(x/y); 的执行结果是:0.6
    B.int x=3,y=5; System.out.println(x/y); 的执行结果是:0
    C.int x=3; float y=5.0f; System.out.println(x/y); 的执行结果是:0.6
    D.int x=3; float y=5.0f; System.out.println((int)(x/y)); 的执行结果是:0

  19. 已知int类型数据的范围是 -2147483648 ~ 2147483647 , 下列代码执行后的结果是()。【D】
    int max=Integer.MAX_VALUE;
    System.out.println(max+1);
    A.Unknown
    B.0
    C.2147483647
    D.-2147483648

第三题:编程题

  1. 写java代码,没有输入,屏幕输出“Hello World”
    输入格式:
    输出格式:Hello World
import java.util.Scanner;
public class Main {public static void main(String[] args) {
// 		Scanner s = new Scanner(System.in);System.out.println("Hello World");}
}
  1. 本题目要求读入若干对整数a和b,然后输出它们的和。
    输入格式:
    在一行中给出一对整数a和b。
    以下输入样例只有两对,实际测试数据可能有多对值。
    输出格式:
    对每一组输入,如果a的绝对值>1000,输出|a|>1000,否则输出a+b的值。
    输入样例:
18 -299
1001 -9
-1001 8

输出样例:

-281
|a|>1000
|a|>1000

源代码:

import java.util.Scanner;
public class Main{public static void main(String[] args){Scanner s = new Scanner(System.in);int a,b;a=s.nextInt();b=s.nextInt();while(true){
//             if(a>1000||a<-1000){
//                 System.out.println("|a|>1000");
//             }if(Math.abs(a)>1000){//两种方法System.out.println("|a|>1000");}else {System.out.println(a+b);}a=s.nextInt();b=s.nextInt();}}
}

相关内容

热门资讯

安卓双系统添加应用,轻松实现多... 你有没有想过,你的安卓手机里可以同时运行两个系统呢?听起来是不是很酷?想象一边是熟悉的安卓系统,一边...
pipo安卓进系统慢,探究pi... 最近是不是发现你的Pipo安卓系统更新或者运行起来特别慢?别急,今天就来给你好好分析分析这个问题,让...
怎样使用安卓手机系统,安卓手机... 你有没有发现,安卓手机已经成为我们生活中不可或缺的一部分呢?从早晨闹钟响起,到晚上睡前刷剧,安卓手机...
双系统安卓安装caj,轻松实现... 你有没有想过,你的安卓手机里装上双系统,是不是就能同时享受安卓和Windows系统的乐趣呢?没错,这...
安卓使用ios系统教程,安卓用... 你是不是也和我一样,对安卓手机上的iOS系统充满了好奇?想要体验一下苹果的优雅和流畅?别急,今天我就...
安卓系统gps快速定位,畅享便... 你有没有遇到过这样的情况:手机里装了各种地图导航软件,但每次出门前都要等上好几分钟才能定位成功,急得...
安卓手机系统更新原理,原理与流... 你有没有发现,你的安卓手机最近是不是总在提醒你更新系统呢?别急,别急,让我来给你揭秘一下安卓手机系统...
安卓系统通知管理,全面解析与优... 你有没有发现,手机里的通知就像是一群调皮的小精灵,时不时地跳出来和你互动?没错,说的就是安卓系统的通...
安卓系统手机哪买,揭秘哪里购买... 你有没有想过,拥有一部安卓系统手机是多么酷的事情呢?想象你可以自由安装各种应用,不受限制地探索各种功...
安卓系统 ipv4,基于安卓系... 你知道吗?在智能手机的世界里,有一个系统可是无人不知、无人不晓,那就是安卓系统。而在这个庞大的安卓家...
目前安卓是什么系统,探索安卓系... 亲爱的读者,你是否曾好奇过,如今安卓系统究竟是什么模样?在这个科技飞速发展的时代,操作系统如同人体的...
安卓6.0系统比5.0,从5.... 你有没有发现,自从手机更新了安卓6.0系统,感觉整个人都清爽了不少呢?没错,今天咱们就来聊聊这个话题...
安卓2.36系统升级,功能革新... 你知道吗?最近安卓系统又来了一次大变身,那就是安卓2.36系统升级!这可不是一个小打小闹的更新,而是...
安卓系统源码怎么打开,并可能需... 你有没有想过,安卓系统的源码就像是一扇神秘的门,隐藏着无数的技术秘密?想要打开这扇门,你得掌握一些小...
安卓8.0系统体验视频,智能革... 你有没有听说安卓8.0系统最近可是火得一塌糊涂啊!作为一个紧跟科技潮流的数码达人,我当然要来给你好好...
宣传系统漫画app安卓,探索安... 亲爱的读者们,你是否曾在某个午后,百无聊赖地打开手机,想要寻找一些轻松愉悦的读物?今天,我要给你介绍...
鸿蒙替换安卓系统吗,开启智能生... 你知道吗?最近科技圈里可是炸开了锅,因为华为的新操作系统鸿蒙系统,据说要大举进军手机市场,替换掉安卓...
手机安卓系统深度清理,解锁手机... 手机里的东西是不是越来越多,感觉就像一个装满了杂物的储物柜?别急,今天就来教你一招——手机安卓系统深...
安卓上的windows系统,融... 你有没有想过,在安卓手机上也能体验到Windows系统的魅力呢?没错,这就是今天我要跟你分享的神奇故...
安卓系统焦点变化事件,Andr... 你知道吗?在安卓系统的世界里,最近发生了一件超级有趣的事情——焦点变化事件。这可不是什么小打小闹,它...