思迁数码科技Java软件工程师笔试真题
选择题
1:Which statements about Java code security are not true?
上海龙凤1314 shlf A.The bytecode verifier loads all classes needed for the execution of a program.
B.Executing code is performed by the runtime interpreter.
C.At runtime the bytecodes are loaded, checked and run in an interpreter.
上海龙凤1314 shlf D.The class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources.
上海龙凤1314 shlf 2:What is the result when you compile and run the following code?
上海龙凤1314 shlf public class Test
{
上海龙凤1314 shlf public void method()
{
for(int i = 0; i < 3; i++)
{
System.out.print(i);
}
System.out.print(i);
}
}
Choices:
What is the result when you compile and run the following code?
public class Test
{
上海龙凤1314 shlf public void method()
{
上海龙凤1314 shlf for(int i = 0; i < 3; i++)
{
System.out.print(i);
}
System.out.print(i);
}
}
Choices:
A.0122
B.0123
C.Compilation error
上海龙凤1314 shlf D.None of these
3:
Give the following code:
public class Example{
public static void main(String args[] ){
上海龙凤1314 shlf int l=0;
do{
System.out.println(“Doing it for l is:”+l);
上海龙凤1314 shlf }while(--l>0)
上海龙凤1314 shlf System.out.println(“Finish”);
}
}
上海龙凤1314 shlf Which well be output:
Give the following code:
public class Example{
public static void main(String args[] ){
int l=0;
do{
System.out.println(“Doing it for l is:”+l);
上海龙凤1314 shlf }while(--l>0)
上海龙凤1314 shlf System.out.println(“Finish”);
}
}
Which well be output:
A.Doing it for l is 3
上海龙凤1314 shlf B.Doing it for l is 1
C.Doing it for l is 2
D.Doing it for l is 0
上海龙凤1314 shlf 4:Math.round(11.5)等於多少?
A.11
B.12
C.11.5
D.none
5:
上海龙凤1314 shlf What will happen when you attempt to compile and run the following code?
int Output = 10;
上海龙凤1314 shlf boolean b1 = false;
上海龙凤1314 shlf if((b1 == true) && ((Output += 10) == 20))
{
上海龙凤1314 shlf System.out.println("We are equal " + Output);
}
else
{
System.out.println("Not equal! " + Output);
}
上海龙凤1314 shlf Choices:
上海龙凤1314 shlf What will happen when you attempt to compile and run the following code?
上海龙凤1314 shlf int Output = 10;
boolean b1 = false;
if((b1 == true) && ((Output += 10) == 20))
{
System.out.println("We are equal " + Output);
}
else
{
上海龙凤1314 shlf System.out.println("Not equal! " + Output);
}
Choices:
上海龙凤1314 shlf A.Compilation error, attempting to perform binary comparison on logical data type
B.Compilation and output of "We are equal 10".
C.Compilation and output of "Not equal! 20".
D.Compilation and output of "Not equal! 10".
6:
上海龙凤1314 shlf What will happen when you attempt to compile and run the following code?
上海龙凤1314 shlf (Assume that the code is compiled and run with assertions enabled.)
上海龙凤1314 shlf public class AssertTest{
public void methodA(int i){
assert i >= 0 : methodB();
System.out.println(i);
}
上海龙凤1314 shlf public void methodB(){
System.out.println("The value must not be negative");
}
上海龙凤1314 shlf public static void main(String args[]){
AssertTest test = new AssertTest();
test.methodA(-10);
}
}
上海龙凤1314 shlf What will happen when you attempt to compile and run the following code?
上海龙凤1314 shlf (Assume that the code is compiled and run with assertions enabled.)
public class AssertTest{
public void methodA(int i){
assert i >= 0 : methodB();
System.out.println(i);
}
public void methodB(){
System.out.println("The value must not be negative");
}
public static void main(String args[]){
AssertTest test = new AssertTest();
上海龙凤1314 shlf test.methodA(-10);
}
}
上海龙凤1314 shlf A.it will print -10
B.it will result in AssertionError showing the message-“the value must not be negative”.
【思迁数码科技Java软件工程师笔试真题】相关文章:
8.微软笔试真题