标签:ali ola 区别 实现 子线程 lang 位运算 ges 输出
QUESTION 46如果if后面没有语句块,就是紧跟的一句语句受if影响
&与&&的区别,&&有短路功能当第一个语句是false时将不判断第二个语句,&符号两边不是boolean值时,执行位运算。
注意第20行代码处是b2=true,只有一个等号;是赋值操作!!!!
QUESTION 47
Given:
如果抛出一个异常,就不会执行下面的内容,而是返回调用产生异常的方法那里去。Error类和Exception类同继承自Throwable类,main函数不能处理Error类异常,所以一个Thorwable被main抛出。
QUESTION 55
Given:
} }
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ? (Choose two.)
A. move the line 12 print statement into the foo() method
B. change line 7 to public synchronized void go() {
C. change the variable declaration on line 2 to private volatile int x;
D. wrap the code inside the foo() method with a synchronized( this ) block
E. wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop
code here }
Answer: AD
子线程和主线程的速度不一样,System.out.println("run.");和System.out.println("End of method.");哪一个首先执行也不一定,但是必须是现输出run再有一个异常。异常输出后还要往下执行。
QUESTION 62 Given:
Date date = new Date();
df.setLocale(Locale.ITALY);
The variable df is an object of typeDateFormat that has been initialized in line 11. What is the result if thiscode is run on December 14, 2000?
A. The value of s is 14-dic-2000.
B. The value of s is Dec 14, 2000.
C. An exception is thrown atruntime.
D. Compilationfails because of an error in line 13.
DateFormat没有setLocale()方法,setLocale是MessageFormat的方法
QUESTION 63
Given:
public class KungFu {
public static voidmain(String[] args) {
Integer x = 400;
Integer y = x;
x++;
StringBuilder sb1 = newStringBuilder("123");
StringBuilder sb2 = sb1;
sb1.append("5");
System.out.println((x==y) +" " + (sb1==sb2));
}
What is the result?
A. true true
B. false true
C. C. true false
D. false false
E. Compilation fails.
F. An exception is thrown atruntime.
Answer: B
sb1,sb2,指向的都是同一个地址;
QUESTION 64
Given that the current directory is empty, and that the user has read and write privileges to the current
directory, and the following:
没有调用创建方法,只是申明了Fiel类
QUESTION 65
Given:
获取的标记与期望类型的模式不匹配
useDelimiter 将此扫描器的分割模式设置为从指定String构造的模式。
Delimiter英文意思为分隔符;useDelimiter( )方法默认以空格作为分隔符;当然也修改,如:
useDelimiter(","); //以‘,‘为分隔符
useDelimiter("\n"); //“\n”换行符(回车)作为输入的分隔符。
QUESTION 67 Given that Triangleimplements Runnable, and:
void go() throws Exception {
Thread t = new Thread(newTriangle());
t.start();
for(int x = 1; x < 100000;x++) {
//insert code here
if(x%100 == 0)System.out.print("g");
} }
public void run() {
try {
for(int x = 1; x < 100000;x++) {
// insert the same code here
if(x%100 == 0)System.out.print("t");
}
} catch (Exception e) { }
Which two statements, insertedindependently at both lines 35 and 41, tend to allow both threads totemporarily pause and allow the other thread to execute? (Choose two.)
A. Thread.wait();
B. Thread.join();
C. Thread.yield();//线程舍弃
D. Thread.sleep(1);// 线程休眠
E. Thread.notify();
Answer: CD
QUESTION 71
Given:
实现了A接口的类的对象a仅仅有x()方法,没有y()方法!
OCJP视频课堂,具体讲解:https://edu.csdn.net/course/detail/7811
标签:ali ola 区别 实现 子线程 lang 位运算 ges 输出
原文地址:http://blog.51cto.com/2096101/2136775