Monday, January 11, 2010

Java Fundmental-II

1. The Java language is:
a. Interpreted at run time.
b. Compiled to obtain executable target files.
c. Designed for recursive string processing.
d. Designed for matrix algorithm processing.

2. The Java language is designed to:
a. Run on a simulated Java machine.
b. Run directly on Intel microprocessors.
c. Designed for RISC computing architectures.
d. Designed for CISC computing architectures.

3. The Java language will run:
a. On any computer where the Java simulated machine is installed.
b. On any computer attached to the Internet.
c. On any computer with a Web browser installed.
d. On any computer which will also run C++.

4. The Java language provides the programmer with:
a. No ability to access or manipulate memory.
b. Protected access to machine memory.
c. Dynamically created data structures linked with pointers.
d. Access to the memory of a local machine through a network.

5. The Java language is:
a. An object oriented programming language.
b. A structured programming language.
c. A procedural programming language.
d. A stack oriented programming language.

6. The Java language was designed:
a. To create event driven programs with graphical interfaces.
b. To unify all different approaches to object orientation.
c. To provide a learning tool for beginning programmers.
d. To force programmers to implement all needed program elements themselves.

7. The Java language has most in common with the following language:
a. C#.                      b. C.                  c. C++.                 d. Basic.
8. The basis for object oriented programming can be found in which of the following?
a. All of the items listed.
b. It is an outgrowth of the availability of powerful hardware.
c. It is useful in the development of graphical user interfaces.
d. It solved some of the problems associated with structured programming.

9. That unit of code in Java that contains the specifications for objects is:
a. A class.          b. A method.         c. An instance variable.      d. A constructor.

10. Which of the following is true?
a. An object receives copies of all instance variables, but shares method code.
b. An object receives copies of all instance variables and all methods.
c. An object receives copies of all methods, but shares instance variables.
d. An object shares both instance variables and methods with other objects.

11. Encapsulation refers to the idea that:
a. Instance variables can only be accessed by means of methods.
b. Methods can only be accessed by means of instance variables.
c. All other methods must be defined within the main() method.
d. Instance variables can only be declared within methods.

12. In order to use objects of a given class the programmer needs to:
a. Know what the methods do, but not how they do it.
b. Know all of the instance variables of the class.
c. Know how the method algorithms were implemented.
d. Know the types of all of the instance variables of the class.

13. Java programs have to be saved with the following extension:
a. .java               b. .txt           c. .doc             d. .xls

14. In Java programs, the name of the class has to:
a. Be the same as the name of the file it is saved in.
b. Be different from the name of the file it is saved in.
c. Be all capital letters.
d. Be all small letters.

Friday, January 01, 2010

Java Fundamental-VI

1. What is the purpose of finalization?
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.


2. What is the difference between the Boolean & operator and the && operator?
- If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.


3. How many times may an object's finalize() method be invoked by the garbage collector?
An object's finalize() method may only be invoked once by the garbage collector.


4. What is the purpose of the finally clause of a try-catch-finally statement?
The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.


5. What is the argument type of a program s main() method?
A program's main() method takes an argument of the String[] type.


6. Which Java operator is right associative?
The = operator is right associative.


7. Can a double value be cast to a byte?
Yes, a double value can be cast to a byte.


8. What is the difference between a break statement and a continue statement?
A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.


9. What must a class do to implement an interface?
It must provide all of the methods in the interface and identify the interface in its implements clause.


10. What is the advantage of the event-delegation model over the earlier event-inheritance model?
The event-delegation model has two advantages over the event-inheritance model. First, it enables event handling to be handled by objects other than the ones that generate the events (or their containers). This allows a clean separation between a component s design and its use. The other advantage of the event-delegation model is that it performs much better in applications where many events are generated. This performance improvement is due to the fact that the event-delegation model does not have to repeatedly process unhandled events, as is the case of the event-inheritance model.

Search Aptipedia