📄 认证与培训 - 希望对大家有帮助(280道考题回忆).mht
字号:
t2=3Dnew=20
=
Thread(run);<BR>t1.start();<BR>t2.start();<BR>}<BR>}
<P>Compile time Error There is no start =
method<BR>Will=20
print in this order 11 22 33=85=85<BR>Will print =
but not=20
exactly in an order (eg: 123124 3=85=85)<BR>Will =
print in=20
this order 12 3=85=85123=85=85<BR>Will print in =
this order 123=85=85?.
<P>Ans:C<BR>9.<BR>class s implements =
Runnable{<BR>int=20
x=3D0,y=3D0;<BR>synchronized void addX(){x++;=20
}<BR>synchronized void addY(){y++; }<BR>void=20
addXY(){x++;y++;}<BR>boolean check() { return =
(x>y)?=20
true:false;)
<P>public void=20
=
run()<BR>{<BR>////<BR>System.out.println(check());=20
}<BR>public static void main(String args[])<BR>{ =
s=20
run=3Dnew s();<BR>Thread t1=3Dnew =
Thread(run);<BR>Thread=20
t2=3Dnew=20
=
Thread(run);<BR>t1.start();<BR>t2.start();<BR>}<BR>}<BR>If=20
this methods are called in which order the check =
will=20
return true?<BR>Select all that apply<BR>call =
addX() and=20
addY() simultaneously for number of times in=20
run()<BR>call addY() and addX() simultaneously =
for=20
number of times in run()<BR>all addXY() for =
number of=20
times in run()
<P>Ans:B,C
<P>10. What is the name of the method used to =
start a=20
thread execution?<BR>A. init();<BR>B. =
start();<BR>C.=20
run();<BR>D. resume();<BR>Ans:B
<P>11. Which two methods may not directly cause =
a thread=20
to stop<BR>executing?<BR>A. sleep();<BR>B. =
stop();<BR>C.=20
yield();<BR>D. wait();<BR>E. notify();<BR>F.=20
notifyAll()<BR>G. synchronized()<BR>Ans:EF
<P>12. class Outer{<BR>class Inner{}<BR>}<BR>How =
will=20
you create an instance of Inner Class out side? =
Select=20
2<BR>Inner a=3D new Inner();<BR>Outer o=3D new =
Outer();Inner=20
a=3D new o.Inner();<BR>Outer o=3D new =
Outer();Outer.Inner a=3D=20
new o.Inner();<BR>Outer.Inner a=3D new =
Outer().new=20
Inner();<BR>Ans:CD
<P>13. What a static inner class can access =
select=20
one<BR>A. Any variables in the enclosing =
scope<BR>B.=20
Final variables in the enclosing scope<BR>C. =
Static=20
variables declared in side the method<BR>D. =
Static=20
variables declared in side the outer =
class<BR>Ans:D
<P>14. What is true about inner class? Select =
one<BR>an=20
Inner class can access all variables in the any=20
enclosing scope<BR>an Inner class can access all =
variables in the enclosing scope<BR>an inner =
class can=20
be declared as private<BR>an Anonymous inner =
class can=20
be extended from class and can implement<BR>an =
interface
<P>Ans:C
<P>15. A ----- is a class that is a collection =
which=20
cannot contain any<BR>duplicate elements which =
maintains=20
its elements in ascending=20
order.<BR>SortedSet<BR>Set<BR>Sorted=20
Map<BR>Collection<BR>TreeSet
<P>Ans: A
<P>16. What is true about Map select one<BR>A =
map will=20
order the elements in an order according the =
key<BR>A=20
map will use unique key to store value<BR>A map =
will use=20
unique key to identify value inside the=20
map<BR>Ans:C<BR>17. Which Method Returns the =
parent part=20
of the pathname of this File<BR>object, or null =
if the=20
name has no parent=20
=
part?<BR>getParent()<BR>getParentDir()<BR>getParentDirectory()<BR>parentD=
irectory()
<P>Ans:a
<P>18. Which class should be used in situations =
that=20
require writing<BR>characters rather than=20
=
bytes.<BR>LineNumberWriter<BR>PrintWriter<BR>PrintStream<BR>PrintOutputRe=
ader<BR>Ans:B
<P>19. To Write End of a File f=3Dnew=20
File(C:\\hello.txt");<BR>new=20
=
RandomAccessFile(f,"rw").writeByte(?;<BR>FileInputStream=20
fis=3Dnew =
FileInputStream(f,true);<BR>DataInputStream=20
d=3Dnew=20
=
DatainputStream(fis);<BR>d.writeBytes(?<BR>FilterInputStream=20
fis=3Dnew =
FilterInputStream(f,true);<BR>DataInputStream=20
d=3Dnew =
DatainputStream(fis);<BR>d.writeBytes(?<BR>D.=20
FileOutputStream fis=3Dnew=20
FileOutputStream(f);<BR>DataOutputStream d=3Dnew =
DataOutputStream(fis);<BR>d.writeBytes(?<BR>E.=20
FilterOutputStream fis=3Dnew=20
FilterOutputStream(f);<BR>DataOutputStream =
d=3Dnew=20
DataOutputStream(fis);<BR>d.writeBytes(?
<P>Ans:C<BR>//Random access file needs to use =
seek() in=20
order to write last
<P>20. Which of the following is the correct =
form of=20
constructor for<BR>PrintWriter?<BR>new =
PrintWriter(new=20
OutputStreamReader(new File(".\hai.txt");<BR>new =
PrintWriter(new File(".\hai.txt");<BR>new=20
PrintWriter(new OutputStream());<BR>21. What is =
the=20
return-type of the getSource of =
ActionEvent?<BR>A.=20
boolean<BR>B. Boolean<BR>C. void<BR>D. ID of the =
event<BR>E. Object
<P>Ans:E<BR>22. To Retrieve the cosine which =
method you=20
will =
use?<BR>cos<BR>cosine<BR>getCos<BR>getCosine
<P>Ans:A<BR>23. Which class is handling Events =
for=20
=
MouseMotionListener?<BR>MouseMotionEvent<BR>MouseEvent<BR>MotionEvent<BR>=
ActionEvent<BR>Ans:B
<P>24. Which of the following will create an =
empty file.=20
select 2<BR>FileInputStream<BR>RandomAccessFile =
is=20
constructed as =
"rw".<BR>FileOutputStream.<BR>Ans:A,B
<P>25. import java.util.Stack;<BR>public class=20
aClass<BR>{<BR>public static void main(String=20
[]agrs)<BR>{<BR>Stack st1 =3D new =
Stack();<BR>Stack st2 =3D=20
new Stack();<BR>new aClass().Method(st1,=20
st2);<BR>System.out.println("st1 has: " +=20
st1);<BR>System.out.println("st2 has: " +=20
st2);<BR>}<BR>private void Method(Stack =
st1,Stack=20
st2)<BR>{<BR>st2.push(new Integer(100));<BR>st1 =
=3D=20
st2;<BR>}<BR>}<BR>A. print<BR>st1 has: []<BR>st2 =
has:=20
[100]<BR>B. error in st1 =3D st2<BR>C. error in =
("st1 has:=20
" + st1)<BR>D. print<BR>st1 has: [100]<BR>st2 =
has:=20
[100]<BR>Ans:A
<P>26. class Super<BR>{<BR>int =
i=3D0;<BR>Super(String=20
s)<BR>{<BR>i=3D10;<BR>}<BR>}<BR>class Sub =
extends=20
Super<BR>{<BR>Sub(String s)<BR>{ i=3D20; =
}<BR>public=20
static void main(String args[])<BR>{<BR>Sub =
b=3Dnew=20
Sub("hello");<BR>System.out.println(i);<BR>}
<P>What will be the value of i.?<BR>A. =
Compilation=20
Error<BR>B. Runtime Error<BR>C. 0<BR>D. 10<BR>E. =
20<BR>Ans:E
<P>27. String s=3D=20
=
"ABCD";<BR>s.concat("E");<BR>s.replace('C','F');<BR>System.out.println(s)=
;
<P>What will be printed out?<BR>A. Compilation =
Error=20
says that String is immutable<BR>B. ABFDE<BR>C.=20
ABCDE<BR>D. ABCD<BR>Ans:D
<P>28. class sree<BR>{<BR>fun(){<BR>static int I =
=3D0;<BR>I++;<BR>}<BR>public static void =
main(String=20
args[])<BR>{<BR>sree obj=3Dnew=20
sree();<BR>obj.fun();<BR>obj.fun();<BR>}<BR>what =
will be=20
the value of I ?<BR>A. Compilation error<BR>B. =
Run time=20
Error<BR>C. 1<BR>D. 2<BR>Ans:A<BR>//you cannot =
declare a=20
static variable inside the mehtod
<P>29. which are the correct forms of =
Overloading=20
Constructors for the<BR>class hai?<BR>public =
void=20
hai(int a)<BR>hai(int a,int b)<BR>public hai(int =
a)<BR>int hai(int c, int d)<BR>int hai()<BR>int=20
hai(String s)<BR>Ans:BC<BR>//contstructors will =
not=20
return any value
<P>Which are the correct forms of overriding for =
the=20
method void hai(int<BR>a,int b)<BR>public void =
hai(int=20
a,int b)<BR>protected void hai(int a,int =
b)<BR>public=20
hai(int a)<BR>int hai(int c, int d)<BR>int =
Hai()<BR>int=20
hai(String s)<BR>Ans:A,B
<P>31. public static void main(String =
args[])<BR>{=20
=
try{<BR>System.out.println("1");<BR>/////AA<BR>}<BR>catch=20
(RuntimeException=20
=
x){<BR>System.out.println("2");<BR>return;<BR>}<BR>catch(Exception=20
=
x){<BR>System.out.println("3");<BR>return;<BR>}<BR>finally{<BR>System.out=
.println("4");<BR>}<BR>System.out.println("5");<BR>}<BR>if=20
there is no Exception in the try block what will =
be the=20
output?<BR>Select all that apply?<BR>A. 1<BR>B. =
2<BR>C.=20
3<BR>D. 4<BR>E. 5<BR>Ans:ade
<P>32. class Sree<BR>{<BR>public static void =
main(String=20
args[])<BR>{ try{<BR>return =
;<BR>}<BR>catch(Exception=20
=
e)<BR>{System.out.println("Exception");}<BR>finally{System.out.println("F=
inally");}<BR>}<BR>}<BR>What=20
will be the out put?<BR>A. Compilation Error =
void main=20
Can't return any value.<BR>B. Prints =
Exception<BR>C.=20
Prints Exception Finally<BR>D. Prints =
Finally<BR>Ans:D
<P>//If there is any value with return then =
result will=20
be compilation<BR>error
<P>class Sree<BR>{<BR>public static void =
main(String=20
args[])<BR>{<BR>System.out.println(hai());<BR>}
<P>static int hai()<BR>{<BR>try{<BR>return=20
1;<BR>}<BR>catch(Exception=20
=
e)<BR>{System.out.println("Exception");}<BR>finally{System.out.println("F=
inally");<BR>return=20
2;}
<P>}<BR>}<BR>What will be the out put?<BR>A. =
Compilation=20
Error void main Can't return any value.<BR>B. =
Prints=20
Exception<BR>C. Prints Exception Finally<BR>D. =
Prints=20
Finally and 1<BR>E.Prints Finally and 2<BR>Ans:E
<P><BR>33. class Jith<BR>{<BR>public static void =
main(String=20
=
args[])<BR>{<BR>try{<BR>mymethod();<BR>}<BR>catch(Exception=20
=
e)<BR>{System.out.println("Exception");}<BR>}<BR>}<BR>How=20
will you declare mymethod so that it will throw =
a=20
Exception? Select<BR>one?<BR>A. In method =
declaration=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -