阿里巴巴笔试题(应届)
- 格式:doc
- 大小:39.00 KB
- 文档页数:6
JA V A基础题
运算与赋值
Operator EX Result,写出各自的所表过的值,a,b的值。
EX Result
+77
-35
a=12; b=++a;
a=12; b=a++;
a=12; b=--a;
a=12; b=a--;
13%6
13/6
246.8+”99”
a=10, b=20; a+=b;
a=5, b=5, a/=b;
String compare
A String s1=”java”;
String s2=”java”
(1)s1= =s2 (2)s1eaquals(2)
Please write true of false:
Result: (1) (2)
B String s=”ja”;
String s1=s+”va”;
String s2=”java”;
(1) s1= = s2 (2) s1.eaquals(s2)
Please write ture of false:
Result: (1) (2)
Method modifier and access control:
accessible to public protected private same class yes yes yes Different Class but same package
Subclass in different package
Non-subclass in different package
Consider the following class:
1.class Test{
2.void test(int i){
3.System.out.println(“I am an int”);
4.}
5.void test(String s){
6.System.out.println(“I am a string.”);
7.}
8.
9.public static void main(string args[]){
10. Test t=new Test();
11. char ch=”y”;
12. t.test(ch);
13. }
14.}
Which of the statements below is true?(Choos one.)
A.Line 5 will not compile,because void methods cannot be overridden.
B.Line 12 will not compile,because there is no version of test( ) that rakes a char
argument.
C.The code will compile but will throw an exception at line 12.
D.The code will compile and produce the following output:I am an int.
E.The code will compile and produce the following output:I am a String.
Which two statements are true for the class java.util.TreeSet?(Choosw two)
A.The elements in the collection are ordered.
B.The collection is guaranteed to be immutable.
C.The elements in the collection are guaranteed to be unique.
D.The elements in the collection are accessed using a unique key.
E.The elements in the collection are guaranteed to be syuchronized.
True or False:Readers have methods that can read and return floats and doubles.
A.Ture
B.False
What will happen when you attempt to compile and run the following code?
public class test{
static{
int x=5;
}
Static int x,y;
Public static void main(string args[]){
x--;
myMethod( );
System.out.println(x+y+ ++x);
}
Public static void myMethod( ){
y=x++ + ++x;
}
}
piletime error
B.prints:1
C.prints:2
D.prints:3
E.prints:7
F.prints:8
given the following code,what will be the output?
class Value{
public int i=15;
public class Test{
public static void main(String argv[]){
Test t=new Test( );
t.first( );
}
public void first( ){
int i=5;
Value v=new Value( );
v.i=25;
second(v,i);
System.out.printin(v.i);
}
Public void second(Value v,int i){
i = 0;
v.i = 20;
Value val = new Value( );
v =val;
System.out.println(v.i+””+i);
}
}
A.15 0 20
B.15 0 15
C.20 0 20
D.0 15 20
场景:有一个登录模块。
有三个USER CASE,登录、密码校验、密码或用户名出错提示处理。
请画出这三者之间的USER CASE图。
What is the difference between ‘= =’operator and the equals( )method?What is the default behavior of the equals( ) method?
What is the difference between the methods,Thread.run( ) and Thread.start( )?
What are the difference between an interface and an abstract class?
What class would you use if you were performing string manipulation?Why?。