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();}}
}

相关内容

热门资讯

安卓如何操控苹果系统,揭秘跨平... 你知道吗?在这个科技飞速发展的时代,安卓和苹果两大操作系统之间的较量可是从未停歇。虽然它们各自有着忠...
安卓系统账户同步数据,畅享无缝... 你有没有遇到过这种情况:手机里存了那么多宝贝照片、重要文件,结果换了个新手机,却发现那些宝贝全都不翼...
安卓系统不停推送广告,安卓系统... 你有没有发现,最近你的安卓手机是不是越来越“热情”了?没错,就是那个不停在你屏幕上跳来跳去的广告!今...
airpods可以和安卓系统,... 你有没有想过,那些炫酷的AirPods竟然也能和安卓手机完美搭配?没错,就是那个我们平时只听说和iP...
安卓系统实体键盘不对,创新与挑... 你是不是也遇到了这个问题?安卓手机的实体键盘突然不对劲了,按下去没反应,或者反应迟钝,简直让人抓狂!...
汽车导航改装安卓系统,安卓系统... 你有没有想过,你的汽车导航系统是不是已经out了?现在,让我来给你揭秘如何给你的爱车来一次科技大变身...
安卓系统如何限制下载,安卓系统... 你有没有发现,手机里的安卓系统越来越智能了?不过,这也意味着有时候我们不小心就会下载一些不想要的软件...
安卓系统调成日语,概要の副標題... 你有没有想过,你的安卓手机竟然可以变成一个日式小天地呢?没错,就是那种动漫里常见的日语界面,是不是听...
男生耳机推荐安卓系统,男生耳机... 耳机可是现代生活中不可或缺的小玩意儿,尤其是对于喜欢听音乐的男生来说,一副好耳机简直就是灵魂的伴侣。...
安卓同版本升级系统,功能优化与... 你知道吗?最近手机界可是热闹非凡呢!各大品牌纷纷推出了安卓同版本升级系统,让我们的手机焕然一新。今天...
安卓更换别的手机系统,轻松切换... 你有没有想过,你的安卓手机用久了,是不是有点审美疲劳了呢?或者,你最近是不是对其他手机系统产生了浓厚...
安卓系统单机神雕侠侣,指尖重温 你有没有想过,在手机上也能体验一把江湖恩怨、侠骨柔肠?没错,就是那个让人心驰神往的《神雕侠侣》!今天...
安卓系统键盘语言切换,安卓系统... 你有没有发现,手机上的安卓系统键盘语言切换功能,简直就像是个神奇的魔法棒,轻轻一点,就能让文字飞舞在...
oppok1安卓系统,性能与体... 你有没有发现,最近手机圈里又掀起了一股热潮?没错,就是OPPO K1这款新机!这款手机不仅外观时尚,...
安卓系统环境的搭建,从零开始构... 想要在电脑上体验安卓系统的魅力,是不是已经跃跃欲试了呢?别急,今天就来手把手教你如何搭建一个属于自己...
【MySQL】锁 锁 文章目录锁全局锁表级锁表锁元数据锁(MDL)意向锁AUTO-INC锁...
【内网安全】 隧道搭建穿透上线... 文章目录内网穿透-Ngrok-入门-上线1、服务端配置:2、客户端连接服务端ÿ...
GCN的几种模型复现笔记 引言 本篇笔记紧接上文,主要是上一篇看写了快2w字,再去接入代码感觉有点...
数据分页展示逻辑 import java.util.Arrays;import java.util.List;impo...
Redis为什么选择单线程?R... 目录专栏导读一、Redis版本迭代二、Redis4.0之前为什么一直采用单线程?三、R...