【286天】我爱刷题系列045(2017.11.18)

叨叨两句

  1. 果真,能长期坚持一件事的同伴真的不多啊,一个一个的,看着看着,就都坚持不下去了。java

  2. 罗胖作的最伟大的一件事,就是把全中国改变意愿最强,最有自驱力的一群人,找了出来,跨年夜,我要和大家在一块儿!app

牛客网——java专项练习025

1

下面哪一个不是标准Statement类?
正确答案: Dthis

  1. Statementcode

  2. PreparedStatement对象

  3. CallableStatement接口

  4. BatchedStatement内存

答案:D
Statement在JDBC中至关于SQL语句的载体
A,Statement是最基本的用法,采用字符串拼接的方式,存在注入漏洞
B,PreparedStatement对Statement中的SQL语句进行预编译,同时检查合法性,效率高
C,CallableStatement接口扩展 PreparedStatement,用来调用存储过程,它提供了对输出和输入/输出参数的支持。CallableStatement 接口还具备对 PreparedStatement 接口提供的输入参数的支持。
D,不是标准的Statement类

2

java如何接受request域中的参数?
正确答案: C字符串

  1. request.getRequestURL()get

  2. request. getAttribute()it

  3. request.getParameter()

  4. request.getWriter()

request.getAttribute()方法返回request范围内存在的对象,而request.getParameter()方法是获取http提交过来的数据。getAttribute是返回对象,getParameter返回字符串。

3

下列说法正确的是()
正确答案: B 你的答案: B (正确)

  1. 在类方法中可用this来调用本类的类方法

  2. 在类方法中调用本类的类方法时可直接调用

  3. 在类方法中只能调用本类中的类方法

  4. 在类方法中绝对不能调用实例方法

B 类方法是指用static修饰的方法,普通方法叫对象方法。 A.this指的是当前对象,类方法依附于类而不是对象this会编译出错 C.类方法中也能够调用其余类的类方法。同时能够经过建立对象来调用普通方法 D.类方法中能够建立对象,因此能够调用实例方法

4

以下哪些是 java 中有效的关键字()
正确答案: A D

  1. native

  2. NULL

  3. false

  4. this

这个关键字常见的坑:
true、false、null都不是关键字
goto、const、是保留的关键字
abstract                continue           for            new        
switch                  default            if             package     
synchronized            do                 goto           private     
this                    break              double         implements   
protected               throw              byte           else       
import                  public             throws         case       
enum                    instanceof         return         transient  
catch                   extends            int            short       
try                     char               final          interface    
static                  void               class          finally   
long                    strictfp           volatile       const      
float                   native             super          while
boolean                 assert
The keywords const and goto are reserved, even though they are not currently used. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs.
While true and false might appear to be keywords, they are technically boolean literals (§3.10.3). Similarly, while null might appear to be a keyword, it is technically the null literal (§3.10.7).
大概意思:const和goto是保留关键字。true和false看起来像关键字,但严格来讲,它们是boolean常量;null看起来也像关键字,但严格来讲,它是null常量。
综上,true,false,null不是关键字。而是常量。

5

下面选项中,哪些是interface中合法方法定义?()
正确答案: A C D

  1. public void main(String [] args);

  2. private int getSum();

  3. boolean setFlag(Boolean [] test);

  4. public float get(int x);

interface中的方法默认为public abstract 的 ,变量默认为public static final
只是方法名称和参数名称取的比较特殊,java中正确的main方法定义是 public static void main(String[] args){ } B: 接口中不能定义私有方法 C 不显示标明方法的访问修饰符,接口中默认是public D get能够做为方法名称,应该无异议