-
1. What is Java?
-
Why was the Java programming language created?
-
*C. Java was created to produce applications for small
-
appliances.(1995年Java衍生自smalltalk最初设计应用于电视机顶盒的嵌入式系统,而后在网络层内意外的大获成就)
-
Which of the following programming paradigms
-
allows a programmer to develop software based on
-
entities that simulate real world concepts?
-
*C. Object Oriented Programming(这门语言可以成为C系列语言中最优秀的,既没有像C++一样的过度设计,又良好的参照了Java的特点)
-
Which one of the following Java keywords is
-
required when declaring the main method that is
-
the start of a Java application?
-
*A. static (每个函数中只有一个main函数,其唯一性就需要被static确定)
-
Which of the following is used to create the file
-
containing the Java instructions?
-
*D. text editor
-
Which of the following is true of the Java
-
programming language?
-
*D. Code is written in small manageable pieces(每个类更像类,而不像C++一样,几乎被公认为是子程序。)
-
Which of the following could possibly cause a
-
runtime error?
-
*C. divide by zero (在Java中,有几种运行时错误,按层次)
-
Which of the following provides the correct
-
definition of an application?
-
*B. Computer programs that accept data and produce
-
useful information.
-
Where can you find the BlueJ IDE?
-
*A. http://www.bluej.org
-
What must all Java applications contain?
-
*C. a main method
-
Which of the following computer components are
-
referred to as hardware?
-
*C. monitor, CPU, and keyboard
-
Which of the following hardware components is
-
considered to be the brain of a computer?
-
*A. CPU
-
Which sequence best describes the physical steps
-
taken to produce a running Java program?
-
*C. Write the program.
-
Compile to bytecode.
-
Run program.
-
Which of the following is an example of a keyword
-
that is used to specify access?
-
*B. public(参照了C)
-
Which of the following computer components is
-
referred to as a peripheral(外设) device?
-
*D. Mouse
-
How can you supply data immediately to your
-
program when you invoke it?
-
*B. By typing it on the command line.
-
Which of the following are used to instruct a program to
-
perform mathematical calculations or a test of data?
-
*D. operators(运算操作符)
-
Which of the following memory types is known as
-
volatile memory?
-
*C. RAM
-
Which of the following programming paradigms
-
requires a programmer to use a divide and conquer
-
approach to software development?
-
*D. Procedural Programming
-
(Procedural programming can sometimes be used as a synonym for imperative programming (specifying the steps the program must take to reach the desired state), but can also refer (as in this article) to a programming paradigm, derived from structured programming, based upon the concept of the procedure call.)
-
---------------------------------------------------
-
What is the extension of a Java bytecode file?
-
*A. .class
-
What are the tools: javac, appletviewer, javadoc,
-
and jar a part of?
-
*B. J2SDK
-
Which of the following is the machine independent
-
part used in the execution of a Java program?
-
*A. bytecode
-
Why do humans need high-level programming
-
languages?
-
*B. Computers process everything in binary and all
-
information must be converted to binary.
-
Which of the following programming paradigms do
-
the Java programming language use?
-
*B. Object Oriented
-
Which of the following JDK utility programs is used
-
to compile a Java source code file into bytecode?
-
*C. javac
-
Which of the following uses the correct syntax for a
-
main() method that starts a Java application?
-
*C. public static void main(String args[])
-
2. Object-Oriented Programming
-
Which of the following terms describes the process
-
of hiding information in an object?
-
*A. Encapsulation 封装
-
Which of the following terms refers to a method
-
that is used to retrieve data from an object?
-
*B. Accessor 检索数据 —》访问器
-
Which of the following is not a compartment of the
-
Rectangle class symbol?
-
*C. Instance variables
-
What does a constructor method do?
-
*D. It specifies the data values an object will store upon
-
creation.(产生数据值)
-
What is "object think"?
-
*B. A term used to describe how a programmer should
-
approach the problem specifications.
-
What is the name of the method that contains the
-
instructions for cleanup before an object is
-
destroyed?
-
*A. Finalizer(Finally类永远是程序最后执行的,这是虚拟机的垃圾回收规定的,我们可以复写,但是默认总存在)
-
What is a class?
-
*D. a blueprint or specification of an object
-
What is the name of the Java library of classes?
-
*A. API( Application Programming Interface )
-
Which of the following words is a keyword from the
-
Java language?
-
*D. private
-
What is the best group of methods for a bank
-
savings account object?
-
*B. get balance, add interest, set balance, get account
-
number, set account number
-
What can be represented as an object?
-
*C. Almost anything can be considered an object.
-
What does a method signature not provide?
-
*C. Object type
-
What is the name of the uniform system of symbols
-
and terms used to communicate the design of
-
classes and applications?
-
*C. UML Unified Modeling Language
-
What is another name for an object identifier?
-
*D. Object reference
-
Task related objects do not contain which of the
-
following items?
-
*B. Client objects
-
When programmers use "public String getName()",
-
what are they calling the objects method getName
-
to do?
-
*B. Go to the object Name to retrieve data (get…set…)
-
When using containment and inheritance, what are
-
two ways that objects can be related?
-
*B. One object may know about another object and one
-
object may be part of another object.
-
Which keyword is used to request that an object be
-
created?
-
*C. new
-
What are mutators(存取器)and constructors called in
-
object speak?
-
*D. Accessors
-
Which of the following choices is an instance of a
-
class Cycle?
-
*A. MountainBike
-
Which of the following terms refers to a method
-
that accomplishes a non-standard task in a class?
-
*D. custom method
-
Which terms are used to describe how an object
-
knows to do things?
-
*A. Behaviors and methods
-
What best describes an accessor?
-
*D. A method that uses standard ways of retrieving data
-
from an object.
-
The term "object attribute" could be best described
-
by which of the following choices?
-
*B. Object attributes are what the "object knows."
-
When using the Java language, a programmer can
-
accomplish many tasks by what means?
-
*C. by describing objects and defining how the objects will
-
interact
-
3. Java Language Elements
-
What is the file extension of a Java source file?
-
*C. .java
-
What does Java use to delineate a block of
-
statements?
-
*A.
-
What refers to a five faceted storage location in
-
memory that is used to store data?
-
*B. Variable
-
What is available to all objects and methods while
-
the program is running?
-
*C. Static storage
-
Which of the following uses the correct syntax to
-
instantiate a class?
-
*D. Point p = new Point();
-
Which of the following Java commands is used to
-
create documentation in HTML format from a Java
-
source code file?
-
*D. javadoc
-
Where does Java store data that is required or
-
referenced by methods?
-
*B. stack
-
Which of the following choices is dynamic and the
-
second fastest storage space?
-
*D. Stack
-
-------------------总结上面的几个题--------------------------------
-
(1) 堆栈。驻留于常规RAM(随机访问存储器)区域,但可通过它的“堆栈指针”获得处理的直接支持。堆栈指针若向下移,会创建新的内存;若向上移,则会释放那些内存。这是一种特别快、特别有效的数据保存方式,仅次于寄存器。创建程序时,Java编译器必须准确地知道堆栈内保存的所有数据的“长度”以及“存在时间”。这是由于它必须生成相应的代码,以便向上和向下移动指针。这一限制无疑影响了程序的灵活性,所以尽管有些Java数据要保存在堆栈里——特别是对象句柄,但Java对象并不放到其中。
-
(2) 堆。一种常规用途的内存池(也在RAM区域),其中保存了Java对象。和堆栈不同,“内存堆”或“堆”(Heap)最吸引人的地方在于编译器不必知道要从堆里分配多少存储空间,也不必知道存储的数据要在堆里停留多长的时间。因此,用堆保存数据时会得到更大的灵活性。要求创建一个对象时,只需用new命令编制相关的代码即可。执行这些代码时,会在堆里自动进行数据的保存。当然,为达到这种灵活性,必然会付出一定的代价:在堆里分配存储空间时会花掉更长的时间!
-
(3) 静态存储。这儿的“静态”(Static)是指“位于固定位置”(尽管也在RAM里)。程序运行期间,静态存储的数据将随时等候调用。可用static关键字指出一个对象的特定元素是静态的。但Java对象本身永远都不会置入静态存储空间。
-
Which of the following terms refers to the usage
-
rules for symbols and keywords of a language?
-
*C. syntax
-
What is the syntax for a multi-line comment in a
-
Java source file?
-
*B. /* multi-line
-
comment */
-
Which javadoc comment-line option includes the
-
version information in the generated HTML
-
documentation?
-
*D. @version
-
Which of the following statements about the Java
-
keywords is true?
-
*B. they can never be used as identifiers
-
What is the syntax for a single line comment in a
-
Java source file?
-
*A. //
-
What is the scope of a local variable in a method?
-
*A. inside the method that declared the variable
-
What is the purpose of including comments in the
-
source code?
-
*A. to communicate with other programmers(and himself as well )
-
Which of the following is a special tag that will
-
insert a frame of text?
-
*B. @return description
-
All the following are Java keywords except :
-
*C. what
-
What uses memory space in the processor and
-
provides the fastest access to the data?
-
*A. Registers
-
Which of the following integral data types can
-
store the largest value?
-
*D. long
-
Which of the following javadoc special tags is
-
Synonymous(同意) with the @throws special tag?
-
*B. @exception
-
Which symbols are used to enclose javadoc
-
comments?
-
*D. /** and */
-
Which of the following choices is a correct
-
identifier?
-
*A. A_Building
-
What tells the JVM how much memory is required
-
when storing data?
-
*D. type of the data
-
What does Java use as a separator in a method
-
parameter list?
-
*C. , (comma)
-
4. Java Operators and Control
-
Structures
-
Which of the following is a valid assignment
-
statement?
-
*B. boolean done = true;
-
What is the result of the following expression?
-
11000101 ^ 10011001
-
*C. 01011100(相同0,不同1)
-
What will happen if a programmer tries to execute
-
the following code?
-
byte num;
-
num = 1 + 3;
-
*D. the code will not compile because of a type error
-
Which of the following lines of code will produce a
-
compilation error?
-
1. public int test(String x, int n ) {
-
2. if ( n == 0) return n(没有;)
-
3. else if (n == 1) {
-
4. if (x !=null ) return 5;
-
5. }
-
6. }
-
*B. line 2
-
The modulus operator is used to obtain which of
-
the following?
-
*A. the remainder in integer division
-
Which argument type does the System.out.println()
-
method require?
-
*B. It requires a String argument.
-
What does the '/u' character represent?
-
*C. The escape sequence to encode a Unicode character
-
What is casting?
-
*A. Converting one object type to another type.
-
Why doesn't this expression throw a null pointer
-
exception?
-
Account acct;
-
if(acct != null && acct.balance > 20.0)
-
expression is never tested.
-
*A. The AND is short-circuited so the second relational if((acct != null )&& (acct.balance > 20.0))
-
Which of the following conversions with primitives
-
are allowed?
-
*D. double to float
-
Which of the following statements best describes a
-
sequence statement structure?
-
*B. The flow of execution in a method proceeds from one
-
statement to the statement following it, in the order they
-
appear in the source file.
-
What is the value of c after the following line of
-
code is executed?
-
a = 2
-
b = 4
-
c = a * b / b + 3 * a;
-
*B. 8
-
What is the result of compiling and executing this
-
code?
-
public class TestShort{
-
public static void main(String[] args)
-
{
-
short num;
-
byte x = 2;
-
byte y = 3;
-
num = x + y;
-
}
-
}
-
*C. The compile will fail because the + operator sees the
-
operands as type int.
-
Which of the following statements regarding shift
-
operators is true?
-
*D. When doing the manipulation of bits on primates
-
larger than 32 bits, the compiler will automatically reduce
-
the primitives to 32 bits.
-
What are legal types for the evaluated expression
-
in a switch statement?
-
*D. char types
-
If a class has a private String field to hold an
-
account number called acctNum, and a public
-
method called getAcctNum() that returns this
-
account number String, which line of code would
-
assign the length of the account number to the variable
-
lenAcct? The reference to this class is named ba.
-
*D. lenAcct = ba.getAcctNum().length();
-
Which of the following operators has the highest
-
precedence?
-
*D. parentheses
-
Is it ever possible to assign the value of variable
-
with a double value to a float variable?
-
*A. Yes, but a type cast must be done and there could be
-
loss of data.(整形截止,再变回整形取值和原来不一样)
-
What happens when the following lines of code are
-
compiled and run?
-
float x;
-
x = 3.4;
-
*A. The code will not compile.
-
Which line of code will correctly assign the value of
-
"passing" to the String msg if the value of points is
-
at least 75?
-
*B. String msg = points >= 75? "passing" : "not passing";
-
What is the value of x after this statement
-
executes?
-
int x = 14/5 * 5;
-
*B. 10 操作过程即自动发生强制类型转换
-
The dot operator is used to do which of the
-
following operations?
-
*D. The dot operator is used to access non-private
-
methods or member data of an object.
-
What is the value of num after this assignment
-
statement?
-
double num = 24.0 / 2.0 * 3 + 2;
-
*C. 38.0
-
Which of the following answers is the correct way
-
to declare a Boolean variable named truth?
-
*A. boolean truth = true;
-
What is the term is used to describe the data flow
-
in and out of a Java program?
-
*B. stream
-
5. Basics of Defining and Using
-
Classes
-
Which best describes the signature of a method?
-
*B. The signature describes the interface to the method:
-
the method name, type, and number of arguments
-
expected.
-
Which of the following instance variables for a
-
BankAccount class would be declared as final?
-
*B. accountNumberID
-
Which of the following illustrates an overloaded
-
constructor?
-
*A. public Person(String name)
-
public Person(String name, int age)
-
Which of the following best describes an object's
-
state?
-
*C. The current data the object is holding.
-
What should a variable name start with in order to
-
comply with improved readability issues?
-
*B. a lowercase letter
-
What is the line number in the code listing when
-
the object x becomes available for destruction?
-
*D. 15
-
How does a method keep track of which object is
-
calling it?
-
*A. Every instance method has a variable called "this",
-
which refers to the current object for which the method is
-
applied.
-
What can be said about a static class variable?
-
*B. Any method will see the same variable.
-
What is required of the method return value(s)?
-
*B. It must be assignment compatible with the signature.
-
Which class is considered immutable?
-
*D. String
-
When an object of a class is instantiated, what is
-
needed to work with that object?
-
*A. a reference to the object
-
What is a reason for writing a "setter" method?
-
*B. A "setter" method provides a way to validate data and
-
maintain consistency among instance variables in a class.
-
What must all methods have?
-
*C. a name and return type
-
What access modifier should be used when
-
declaring attributes?
-
*A. private
-
A math-tutor application is being created that
-
students will use to practice addition skills. Which
-
of the following would be defined as an object in
-
this application?
-
*C. An addition problem.
-
What is the proper order for object creation?
-
*C. memory allocation explicit initialization constructor is executed a reference variable is assigned
-
What is a reason for writing a "getter" method?
-
*B. All data in a class must be declared as private and a
-
"getter" method is the only way to access it.
-
Which of the following statements is true about the
-
main() method of an application?
-
*D. The main() method in a class declared as public is the
-
starting point for the execution of an application.
-
How should data that is final and used outside the
-
object be declared?
-
*B. public
-
A static method can only access static class
-
variables. How does this affect the main() method?
-
*C. main() cannot access any instance variables of the class
-
Choose the correct sequence of steps used to
-
design a class.
-
*A. Design the attributes and behaviors of the class.
-
Define the class.
-
Create an object of the class.
-
Use the object.
-
Where is method data stored?
-
*C. the stack
-
What should a constant name start with in order to
-
comply with improved readability issues?
-
*A. an uppercase letter (增加可读性,常量使用大写的,而相同的问题还有:类使用)
-
How does an object without an explicit constructor
-
get created?
-
*A. The compiler inserts a constructor.
-
What is the lifetime of an object or method variable
-
in Java?
-
*B. duration of the defining code block