SCJP刷题学习笔记(Part eleven)

本文是作者在准备SCJP(Sun Certified Programmer for Java Platform)考试过程中整理的学习笔记,主要涵盖了Java基础知识、语法、类与对象、接口和多线程等关键知识点,旨在帮助读者巩固理解并为考试做好准备。
摘要由CSDN通过智能技术生成
QUESTION 101
Given the code fragment:
final String  str1 ="JAVA";
StringBuffer strBuf =new StringBuffer("Course");
UnaryOperator<String> u =(str2) ->str1.concat(str2);//line2
UnaryOperator<String> c =(str3) ->str3.toLowerCase();
System.out.println(u.apply(c.apply(strBuf))); //line1

 

What is the result?
A. A compilation error occurs at line n1.
B. courseJava
C. Javacourse
D. A compilation error occurs at line n2.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 102
Given:
class Engine {
double fuelLevel;
Engine(int fuelLevel){this.fuelLevel=fuelLevel;}
public void start() {
	//line1
	System.out.println("Started");				
}
public void stop() {System.out.println("Stopped");}
 }

 

Your design requires that:
fuelLevel of Engine must be greater than zero when the start() method is invoked.
The code must terminate if fuelLevel of Engine is less than or equal to zero.
Which code fragment should be added at line n1 to express this invariant condition?
A. assert (fuelLevel) : “Terminating…”;
B. assert (fuelLevel > 0) : System.out.println (“Impossible fuel”);
C. assert fuelLevel < 0: System.exit(0);
D. assert fuelLevel > 0: “Impossible fuel” ;
Correct Answer: C
Section: (none)
Explanation Explanation/Reference:
 
 
 
QUESTION 103
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值