- 讲师:刘萍萍 / 谢楠
- 课时:160h
- 价格 4580 元
特色双名师解密新课程高频考点,送国家电网教材讲义,助力一次通关
配套通关班送国网在线题库一套
百度广告
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;
责编:罗莉
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
点击加载更多评论>>