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

叨叨两句

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

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

牛客网——java专项练习025

1

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

  1. Statement

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

  2. request. getAttribute()

  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可以作为方法名称,应该无异议
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值