电话:0731-83595998
导航

SCJP试题-SCJPMockExam3

来源: 2017-12-19 10:52

 百度广告

Question 1)
abstract class Base{
public void another(){
}

public class Abs extends Base{
Abs a = new Abs();
}
System.out.println("My Func");
public void amethod(){
}

1) The code will compile and run, printing out the words "My Func"
3) The code will compile but complain at run time that the Base class has non abstract methods

Answer to Question 1


Question 2)

What will happen when you attempt to compile and run this code?

public class MyMain{
System.out.println("Hello cruel world");
}

1) The compiler will complain that main is a reserved word and cannot be used for a class
3) The code will compile but will complain at run time that no constructor is defined

Answer to Question 2


Question 3)

1) public
3) friendly
5) vagrant

Answer to Question 3


Question 4)

class Base{
public void another(){
}

public class Abs extends Base{
Abs a = new Abs();
}

public void myfunc(){
}

public void amethod(){
}
1) The code will compile and run, printing out the words "My Func"
3) The code will compile but complain at run time that the Base class has non abstract methods

Answer to Question 4

--------------------------------------------------------------------------------

Question 5)

1) To get to access hardware that Java does not know about
3) To write optimised code for performance in a language such as C/C++

Answer to Question 5

--------------------------------------------------------------------------------

Question 6)

class Base{
System.out.println("amethod");
}

public class Fin extends Base{
Base b = new Base();
}

1) Compile time error indicating that a class with any final methods must be declared final itself
3) Run time error indicating that Base is not defined as final

Answer to Question 6


Question 7)

public class Mod{
}

}
2) Error at compilation native method must return value
4) Compilation and execution without error

Answer to Question 7

--------------------------------------------------------------------------------

Question 8)

private class Base{}
transient int iVal;
}

1)Compile time error: Base cannot be private
3)Compile time error transient not a data type

Answer to Question 8

--------------------------------------------------------------------------------

Question 9)

//File P1.java
class P1{
System.out.println("What a fancy method");
}
public class P2 extends P1{
}

1) Both compile and P2 outputs "What a fancy method" when run
3) Both compile but P2 has an error at run time

Answer to Question 9


Question 10)

public class MyAr{
int i = new int;
}
1) An error at compile time
3) The value 0 will be output

Answer to Question 10
Question 11) 

1)myarray.length();
3)myarray.size

Answer to Question 11


Question 12)

import java.awt.*;
public static void main(String argv){
fa.setSize(400,300);

}

FlowAp(){
add(new Button("Two"));
add(new Button("Four"));

}//End of Application
2) A Frame with buutons marked One to four running from the top to bottom
4) An Error at run time indicating you have not set a LayoutManager

Answer to Question 12


Question 13)

1) North, South,East,West
3) Pass a X/Y percentage parameter to the add method

Answer to Question 13)



How do you change the current layout manager for a container

1) Use the setLayout method
3) Use the setLayoutManager method

Answer to Question 14)


Question 15)

1) ipadx
3) insets

Answer to Question 15)


Question 16)

import java.awt.*;
public static void main(String argv){
}

CompLay(){
p.setBackground(Color.pink);
p.add(new Button("Two"));
add("South",p);
setSize(300,300);
}
1) The buttons will run from left to right along the bottom of the Frame
3) The buttons will not be displayed

Answer to Question 16)


Question 17)

1) It is a field of the GridBagLayout manager for controlling component placement
3) A valid setting for the anchor field is GridBagConstraints.NORTH

Answer to Question 17)


Question 18)

public class Bground extends Thread{
Bground b = new Bground();
}
for (int i = 0; i < 10; i++){
}
}
2) A run time error indicating that no run method is defined for the Thread class
4) Clean compile but no output at runtime

Answer to Question 18)


Question 19)

1) true

Answer to Question 19)


Question 20)

1) A vector of arrays for a 2D geographic representation
3) A class for containing unique vector elements

Answer to Question 20)


Question 21)

1) An exception is thrown if you attempt to add an element with a duplicate value
3) A set may contain elements that return duplicate values from a call to the equals method

Answer to Question 21)


Question 22)

1) The program exits via a call to System.exit(0);
3) A call to the thread's stop method.



Question 23)

1) The class can access any variable
3) The class can only access transient variables

Answer to Question 23)


Question 24)

Under what circumstances might you use the yield method of the Thread class

1) To call from the currently running thread to allow another thread of the same or higher priority to run
3) To allow a thread of higher priority to run

Answer to Question 24)


Question 25)

public class Hope{
Hope h = new Hope();

protected Hope(){
System.out.println(i);
}

1) Compilation error: Constructors cannot be declared protected
3) Compilation and running with output 0 to 10

Answer to Question 25)


Question 26)

public class MySwitch{
MySwitch ms= new MySwitch();
}


int k=10; 
default: //Put the default at the bottom, not here
break; 
System.out.println("ten");
System.out.println("twenty"); 
}
}
2) Compile time error target of switch must be an integral type
4) Compile and run with output of the single line "ten"

Answer to Question 26)


Question 27)

1) System.free();
3) System.out.gc();

Answer to Question 27)


Question 28)

What will happen when you attempt to compile and run the following code

public class As{
int j;
boolean b;
As a = new As();
}
System.out.println(j);
}

1) Compilation succeeds and at run time an output of 0 and false
3) Compile time error b is not initialised

Answer to Question 28)


Question 29)

What will happen when you attempt to compile and run the following code with the command line "hello there"

public class Arg{
public static void main(String argv){
}

public void amethod(){
}
1) Compile time error
3) Compilation and output of "there"

Answer to Question 29)


Question 30)

public class StrEq{
StrEq s = new StrEq();
private StrEq(){
String s2 = new String("Marcus");
System.out.println("we have a match");
System.out.println("Not equal");
}
1) Compile time error caused by private constructor
3) Output of "Not equal"

Answer to Question 30)


Question 31)

import java.io.*;
public static void amethod()throws FileNotFoundException{}

public class ExcepDemo extends Base{
ExcepDemo e = new ExcepDemo();

public static void amethod(){}
try{
System.out.println("Pausing");
System.out.println("Continuing");
}catch(IOException ioe) {}

}

1)Compile time error caused by protected constructor
3) Runtime error caused by amethod not declaring Exception

Answer to Question 31)


Question 32)

What will happen when you attempt to compile and run this program

public class Outer{
public static void main(String argv){
i.showName();
private class Inner{
void showName(){
}
}
2) Compile and run with output of "Inner"
4) Compile time error because of the line creating the instance of Inner

Answer to Question to 32


Question 33)

//Demonstration of event handling

import java.awt.event.*;
public class MyWc extends Frame implements WindowListener{
MyWc mwc = new MyWc();
public void windowClosing(WindowEvent we){
}//End of windowClosing
setSize(300,300);
}
1) Error at compile time
3) Compilation but no output at run time

Answer to Question 33)


Question 34)

public class MyAr{
MyAr m = new MyAr();
}
static int i;

编辑推荐:

下载Word文档

温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)

网络课程 新人注册送三重礼

已有 22658 名学员学习以下课程通过考试

网友评论(共0条评论)

请自觉遵守互联网相关政策法规,评论内容只代表网友观点!

最新评论

点击加载更多评论>>

精品课程

更多
10781人学习

免费试听更多

相关推荐
图书更多+
  • 电网书籍
  • 财会书籍
  • 其它工学书籍
拼团课程更多+
  • 电气拼团课程
  • 财会拼团课程
  • 其它工学拼团
热门排行

长理培训客户端 资讯,试题,视频一手掌握

去 App Store 免费下载 iOS 客户端