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

相关内容

热门资讯

los系统和安卓系统的区别,两... 你有没有想过,为什么你的手机有时候运行得那么顺畅,有时候又卡得像蜗牛呢?这背后其实隐藏着两个大玩家—...
安卓系统可以安装cad软件,安... 你有没有想过,在安卓手机上也能轻松安装CAD软件呢?没错,就是那个专业的设计软件,以前只能在电脑上操...
车载ce系统与安卓系统的区别,... 你有没有想过,为什么你的车载系统有时候那么不智能,而安卓手机却总能给你带来惊喜?今天,就让我带你深入...
苹果6s系统换安卓系统,体验安... 你有没有想过,把你的苹果6s换成安卓系统呢?想象那流畅的触控体验,加上安卓那丰富的应用和可定制的界面...
安卓转移ios健康系统,探索健... 你有没有想过,从安卓手机转到iOS设备后,那些积累的健康数据怎么办呢?别急,今天就来给你详细解析如何...
安卓系统如何换微信号,教你如何... 你是不是也和我一样,对安卓系统换微信号这个话题感兴趣呢?毕竟,谁不想偶尔换个心情,换个昵称呢?好啦,...
安卓机清理系统内存,提升手机运... 手机用久了是不是感觉越来越卡?别急,今天就来教你怎么给安卓机清理系统内存,让你的手机焕发新生!一、内...
安卓子系统要求CPU,安卓子系... 你知道吗?最近在安卓系统圈子里,有个话题可是热得不得了,那就是安卓子系统对CPU的要求。这可不是小事...
安卓系统排名第几,引领智能时代... 你知道吗?在智能手机的世界里,有一个系统可是当之无愧的“王者”——那就是安卓系统!今天,就让我带你一...
阿里云是不是安卓系统,引领安卓... 最近是不是有很多小伙伴在问:“阿里云是不是安卓系统?”这个问题可真是让人好奇啊!咱们就来好好探讨揭开...
安卓系统音量调节的文件,安卓系... 你有没有遇到过这种情况:手机音量调得刚刚好,突然间就变得忽高忽低,让人听得心烦意乱?别急,今天就来跟...
平板刷安卓10原生系统,平板新... 你有没有想过,你的平板电脑也能拥有安卓10的原生系统呢?没错,就是那个流畅又强大的系统,现在它也能在...
安卓系统怎么设定位手机,安卓系... 你有没有想过,你的安卓手机是怎么知道你在哪儿的呢?没错,就是定位功能!这可是现代智能手机的一大亮点,...
升级的安卓系统怎样降级,安卓系... 你有没有遇到过这种情况?手机里的安卓系统突然升级了,结果发现新系统有点小bug,或者某些功能变得不那...
安卓刷机怎么升级系统,轻松实现... 你有没有发现,你的安卓手机最近有点儿慢吞吞的,是不是也想给它来个“大变身”,让它焕发新生呢?没错,刷...
安卓系统迷你小音响,便携式音乐... 你有没有想过,在忙碌的生活中,给自己一个小小的音乐角落,让心情随着音符跳动呢?今天,就让我带你走进一...
老安卓系统怎么删除页面,老安卓... 你有没有发现,手机里的安卓系统用久了,页面上的应用图标就像小山一样堆得高高的?有时候,看着这些图标,...
安卓手机死屏重置系统,轻松解决... 手机突然死屏了,是不是心里一紧?别慌,今天就来跟你聊聊安卓手机死屏后如何重置系统,让你轻松解决这个小...
安卓系统高怎么运行,解锁流畅体... 手机里的安卓系统突然变得卡顿起来,是不是让你感觉像是在迷宫里找出口?别急,今天就来给你支几招,让你的...
安卓系统新消息弹屏,体验升级 你知道吗?最近安卓系统又来了一大波新消息,这可真是让人兴奋不已!想象当你正在专心致志地刷着手机,突然...