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

相关内容

热门资讯

电视安卓系统哪个品牌好,哪家品... 你有没有想过,家里的电视是不是该升级换代了呢?现在市面上电视品牌琳琅满目,各种操作系统也是让人眼花缭...
安卓会员管理系统怎么用,提升服... 你有没有想过,手机里那些你爱不释手的APP,背后其实有个强大的会员管理系统在默默支持呢?没错,就是那...
安卓系统软件使用技巧,解锁软件... 你有没有发现,用安卓手机的时候,总有一些小技巧能让你玩得更溜?别小看了这些小细节,它们可是能让你的手...
安卓系统提示音替换 你知道吗?手机里那个时不时响起的提示音,有时候真的能让人心情大好,有时候又让人抓狂不已。今天,就让我...
安卓开机不了系统更新 手机突然开不了机,系统更新还卡在那里,这可真是让人头疼的问题啊!你是不是也遇到了这种情况?别急,今天...
安卓系统中微信视频,安卓系统下... 你有没有发现,现在用手机聊天,视频通话简直成了标配!尤其是咱们安卓系统的小伙伴们,微信视频功能更是用...
安卓系统是服务器,服务器端的智... 你知道吗?在科技的世界里,安卓系统可是个超级明星呢!它不仅仅是个手机操作系统,竟然还能成为服务器的得...
pc电脑安卓系统下载软件,轻松... 你有没有想过,你的PC电脑上安装了安卓系统,是不是瞬间觉得世界都大不一样了呢?没错,就是那种“一机在...
电影院购票系统安卓,便捷观影新... 你有没有想过,在繁忙的生活中,一部好电影就像是一剂强心针,能瞬间让你放松心情?而我今天要和你分享的,...
安卓系统可以写程序? 你有没有想过,安卓系统竟然也能写程序呢?没错,你没听错!这个我们日常使用的智能手机操作系统,竟然有着...
安卓系统架构书籍推荐,权威书籍... 你有没有想过,想要深入了解安卓系统架构,却不知道从何下手?别急,今天我就要给你推荐几本超级实用的书籍...
安卓系统看到的炸弹,技术解析与... 安卓系统看到的炸弹——揭秘手机中的隐形威胁在数字化时代,智能手机已经成为我们生活中不可或缺的一部分。...
鸿蒙系统有安卓文件,畅享多平台... 你知道吗?最近在科技圈里,有个大新闻可是闹得沸沸扬扬的,那就是鸿蒙系统竟然有了安卓文件!是不是觉得有...
宝马安卓车机系统切换,驾驭未来... 你有没有发现,现在的汽车越来越智能了?尤其是那些豪华品牌,比如宝马,它们的内饰里那个大屏幕,简直就像...
p30退回安卓系统 你有没有听说最近P30的用户们都在忙活一件大事?没错,就是他们的手机要退回安卓系统啦!这可不是一个简...
oppoa57安卓原生系统,原... 你有没有发现,最近OPPO A57这款手机在安卓原生系统上的表现真是让人眼前一亮呢?今天,就让我带你...
安卓系统输入法联想,安卓系统输... 你有没有发现,手机上的输入法真的是个神奇的小助手呢?尤其是安卓系统的输入法,简直就是智能生活的点睛之...
怎么进入安卓刷机系统,安卓刷机... 亲爱的手机控们,你是否曾对安卓手机的刷机系统充满好奇?想要解锁手机潜能,体验全新的系统魅力?别急,今...
安卓系统程序有病毒 你知道吗?在这个数字化时代,手机已经成了我们生活中不可或缺的好伙伴。但是,你知道吗?即使是安卓系统,...
奥迪中控安卓系统下载,畅享智能... 你有没有发现,现在汽车的中控系统越来越智能了?尤其是奥迪这种豪华品牌,他们的中控系统简直就是科技与艺...