Showing posts with label Java Programming (Set V). Show all posts
Showing posts with label Java Programming (Set V). Show all posts

Wednesday, August 6, 2008

Java Programming - 15

LIST OF ATTEMPTED QUESTIONS AND ANSWERS

Question: Java defines two ways when instantiating an object, such as :-
Correct Answer: Can implement the runnable interface , Can extend
the thread class
Your Answer: Can implement the runnable interface , Can extend the
thread class , New class

True/False
Question: Java allows loops to be nested.
Correct Answer: True
Your Answer: True

Multiple Choice Single Answer
Question: If omit the package statement, which names are put into
defualt pacakge?
Correct Answer: class
Your Answer: method

True/False
Question: The switch statement does not require a break.
Correct Answer: False
Your Answer: False

Multiple Choice Single Answer
Question: What is a data structure that controls the state of a
collection of threads as a whole?
Correct Answer: Thread group
Your Answer: Exceptions

Multiple Choice Multiple Answer
Question: Main thread is important for which two reasons?
Correct Answer: It is thread from which other "child" thread will be
swapped , Often it must be the last thread to finish execution because
It performs various shutdown actions
Your Answer: It is thread from which other "child" thread will be
swapped , It is current thread

Select The Blank
Question: For externalizable objects the ________ is solely
responsible for the external format of its contents.
Correct Answer: Class
Your Answer: Method

Multiple Choice Multiple Answer
Question: Which are keywords in Java?
Correct Answer: Extends , Synchronized , Sizeof
Your Answer: Extends , Synchronized

True/False
Question: Transient variable is variable that may not be serialized.
Correct Answer: True
Your Answer: False

True/False
Question: A thread can be blocked when waiting for a resource.
Correct Answer: True
Your Answer: True

Multiple Choice Multiple Answer
Question: What are different modifiers?
Correct Answer: Private , Protected , Final
Your Answer: Private , Protected

Select The Blank
Question: The explicit drop of an object reference by setting the
value of a variable, whose data type is a reference type of ________.
Correct Answer: Null
Your Answer: Null

Match The Following
Question Correct Answer Your Answer
The data, or variable, defined Instance variable. Instance variable.
within a class
General form of Cast (target--type)value (target--type)value
Determine the relationship that Relational Operator Relational Operator
The secondary versions of the Short-Circuit Logical Operators Logical Operator
Boolean AND and OR operators

True/False
Question: With java Type Casts are checked at both compile-time and
runtime.
Correct Answer: True
Your Answer: False

Multiple Choice Single Answer
Question: Which statement provides an easy way to dispatch execution
to different parts of your code based on the value of an expression?
Correct Answer: Switch
Your Answer: Switch

Multiple Choice Multiple Answer
Question: What all the run( ) method can do?
Correct Answer: Can call other method , Declare variable
Your Answer: Can call other method , Declare variable , Create
object

Multiple Choice Single Answer
Question: How many types of literals are there?
Correct Answer: Number literals, character literals, boolean
literals, string literals, etc.
Your Answer: Only boolean and string literals

Multiple Choice Single Answer
Question: What is an array?
Correct Answer: It is value collection of same type of data type
Your Answer: It is value collection of same type of data type

Multiple Choice Multiple Answer
Question: Which of these lines of code will compile?
Correct Answer: short s = 20; , char c = 32; , double d = 1.4;
Your Answer: byte b = 128; , char c = 32;

Multiple Choice Single Answer
Question: How do you assign values to variables?
Correct Answer: By using the assignment operator =.
Your Answer: By using the assignment operator =.

Select The Blank
Question: ________ is the logical construct upon which the entire
java language is built.
Correct Answer: Class
Your Answer: Method

Multiple Choice Single Answer
Question: How multidimensional array is declared?
Correct Answer: int[4] [5];
Your Answer: int[4] [5];

True/False
Question: The for statement loop can be infinite.
Correct Answer: True
Your Answer: True

Select The Blank
Question: ________ are stored in hierarchical manner.
Correct Answer: Packages
Your Answer: Packages

Multiple Choice Multiple Answer
Question: When might your program wish to run the garbage collector?
Correct Answer: Before it enters a compute-intense section of code ,
Before it enters a memory-intense section of code , When it knows there
will be some idle time
Your Answer: Before it enters a memory-intense section of code ,
When it knows there will be some idle time , Before objects are finalized

Multiple Choice Multiple Answer
Question: Which of the following are mathematical Expressions?
Correct Answer: (+ +) , (+ =) , (- =)
Your Answer: (+ +) , (- +)

Multiple Choice Single Answer
Question: What is a string?
Correct Answer: A combination of characters called as string
Your Answer: A combination of characters called as string

Multiple Choice Single Answer
Question: What is meant by garbage collection?
Correct Answer: Object is no longer referred to by any variable
Your Answer: Object is no longer referred to by any variable

True/False
Question: Casting occurs commonly between numeric types
Correct Answer: True
Your Answer: False

Select The Blank
Question: ________ is an instance of a class that implements the
runnable interface.
Correct Answer: threadOb
Your Answer: threadA

True/False
Question: Integer can Cast to byte value.
Correct Answer: False
Your Answer: True

Match The Following
Question Correct Answer Your Answer
Derived class Subclass of protection Superclass
Class Interface Directories
Packages Directories Excpetion
Specifier Protected Protected

True/False
Question: A thread can be preempted by a higher priority thread.
Correct Answer: True
Your Answer: True

Multiple Choice Multiple Answer
Question: By Providing the interface keyword, Java allows you to
fully utilize the which aspect of polymorphism?
Correct Answer: One interface , Multiple methods
Your Answer: One interface , Multiple methods , Derived

Select The Blank
Question: Anonymous classes be implemented in an ________.
Correct Answer: Interface
Your Answer: Interface

True/False
Question: Interface can be extended.
Correct Answer: True
Your Answer: False

Multiple Choice Multiple Answer
Question: There are two distinct types of multitasking. Which are
those?
Correct Answer: Process based , Thread-base
Your Answer: Process based , Thread-base

Multiple Choice Single Answer
Question: Java provides built-in support for which programming?
Correct Answer: Multithreaded
Your Answer: Multithreaded

Multiple Choice Single Answer
Question: The argument to which specifies the delayperiod in
milliseconds
Correct Answer: sleep( )
Your Answer: sleep( )

True/False
Question: The switch differs from the if in that switch can only
test for equality, whereas if can evaluate any type of Boolean expression.
Correct Answer: True
Your Answer: True

Select The Blank
Question: ________ is referred by a variable candidate for garbage
collection when the variable goes out of scope.
Correct Answer: Objects
Your Answer: Class

Java Programming - 14

LIST OF ATTEMPTED QUESTIONS AND ANSWERS

Select The Blank
Question: After calling start( ) NewThread, constructor returns to
________.
Correct Answer: main( )
Your Answer: main( )

True/False
Question: Nested if is less efficient then switch statement.
Correct Answer: True
Your Answer: True

Match The Following
Question Correct Answer Your Answer
Constructor Initialization object Initialization object
Parameters Method Generalized Method Generalized
Memory deallocation Garbage Collection Garbage Collection
This Current Object Current Object

Multiple Choice Multiple Answer
Question: Which thread is created automatically when the program is
started?
Correct Answer: Main thread
Your Answer: Main thread , Current thread

Select The Blank
Question: When java program starts up, one thread begin runing and
it is called ________thread.
Correct Answer: main( )
Your Answer: main( )

Multiple Choice Single Answer
Question: Multiple Choice Single Response
Correct Answer: Object oriented programming.
Your Answer: Systems Programming.

Multiple Choice Single Answer
Question: Which statement will always execute the body of a loop at
least once?
Correct Answer: Do
Your Answer: Do

True/False
Question: In While loop condition can be any Boolean expression
Correct Answer: True
Your Answer: True

Multiple Choice Multiple Answer
Question: By Providing the interface keyword, Java allows you to
fully utilize the which aspect of polymorphism?
Correct Answer: One interface , Multiple methods
Your Answer: One interface , Multiple methods

True/False
Question: Short data type range is -30,376 to 32768.
Correct Answer: False
Your Answer: False

Multiple Choice Single Answer
Question: Which is a public static member of thread?
Correct Answer: Currenthread( )
Your Answer: Currenthread( )

Multiple Choice Multiple Answer
Question: Which of the following is the declaration of an array of
string objects?
Correct Answer: String[ ] s; , String [ ]s: , String[ s]:
Your Answer: String[ s]: , String s[ ]:

Multiple Choice Multiple Answer
Question: There are two distinct types of multitasking. Which are
those?
Correct Answer: Process based , Thread-base
Your Answer: Process based , Thread-base

Select The Blank
Question: ________ is probably the least used java data type
Correct Answer: short
Your Answer: short

True/False
Question: Casting between primitive types allows conversion of one
primitive type to another.
Correct Answer: True
Your Answer: True

Multiple Choice Multiple Answer
Question: What are different modifiers?
Correct Answer: Private , Protected , Final
Your Answer: Private , Protected , Final

Multiple Choice Single Answer
Question: A Java application can execute anywhere on the network,
this implements that Java is :-
Correct Answer: Architecture neutral
Your Answer: Architecture neutral

Multiple Choice Single Answer
Question: Java Applets are intelligent programs means :-
Correct Answer: They can react to user input and dynamically change.
Your Answer: They have additional intelligence.

Select The Blank
Question: The name of the new thread is specified by ________.
Correct Answer: threadName
Your Answer: Newthread

Select The Blank
Question: ________ is referred by a variable candidate for garbage
collection when the variable goes out of scope.
Correct Answer: Objects
Your Answer: Objects

Select The Blank
Question: The ________ repeat a set of code while the condition is
false.
Correct Answer: While loop
Your Answer: For

Multiple Choice Single Answer
Question: Select the facility provided along with JVM which enhances
speed of execution :-
Correct Answer: Just-In-Time (JIT) compiler.
Your Answer: Just-In-Time (JIT) compiler.

Select The Blank
Question: ________ is an instance of the class.
Correct Answer: Object
Your Answer: Object

Multiple Choice Single Answer
Question: What is a data structure that controls the state of a
collection of threads as a whole?
Correct Answer: Thread group
Your Answer: Thread group

Multiple Choice Single Answer
Question: Which statement used inside a set of nested loops, will
only break out of the innermost loop?
Correct Answer: Break
Your Answer: Break

Multiple Choice Multiple Answer
Question: Which are the keywords use in switch statement?
Correct Answer: Case , Default
Your Answer: Case , Default

Multiple Choice Single Answer
Question: The argument to which specifies the delayperiod in
milliseconds
Correct Answer: sleep( )
Your Answer: sleep( )

Multiple Choice Multiple Answer
Question: Which loops can be nested in java?
Correct Answer: While , Do-while , For
Your Answer: While , Do-while , For

True/False
Question: If the break statement is omited in switch statement, then
execution will continue on into the next case.
Correct Answer: True
Your Answer: True

Match The Following
Question Correct Answer Your Answer
Exit any loop Break Exit
If Else Else
Loop While While
Jump Break, continue, return Break, continue, return

Multiple Choice Single Answer
Question: To import a class, what is a syntax used?
Correct Answer: import classname;
Your Answer: import classname;

Select The Blank
Question: The ________ keyword halts the execution of the current
loop and forces control out of the loop.
Correct Answer: Break
Your Answer: Break

Multiple Choice Multiple Answer
Question: Java's multithreading system is built upon :-
Correct Answer: Thread class , Its methods , Companion interface
Your Answer: Thread class , Its methods , Companion interface

True/False
Question: When an object is referenced, it mean that it has been
identified by the finalizer method for garbage collection.
Correct Answer: False
Your Answer: True

Multiple Choice Single Answer
Question: Which Control Statements allow the program to choose
different paths of execution?
Correct Answer: Selection
Your Answer: Selection

Multiple Choice Multiple Answer
Question: Method definition has four parts, they are :-
Correct Answer: Name of the method , Type of object , List of
parameters
Your Answer: Name of the method , List of parameters

Select The Blank
Question: There are ________ kinds of Floating point type
Correct Answer: Two
Your Answer: Two

Multiple Choice Multiple Answer
Question: What returns a reference to the thread in which it is
called?
Correct Answer: Method , Class , Object
Your Answer: Method , Class , Object

Multiple Choice Single Answer
Question: Which statement defines a name space in which classes are
stored?
Correct Answer: package
Your Answer: objects

Select The Blank
Question: ________ is an instance of a class that implements the
runnable interface.
Correct Answer: threadOb
Your Answer: threadOb

Multiple Choice Multiple Answer
Question: The Stack performs which two function?
Correct Answer: pop( ) , push( )
Your Answer: pop( ) , push( )

True/False
Question: The for statement loop can be infinite.
Correct Answer: True
Your Answer: True

True/False
Question: A thread's priority is used to decide when to switch from
one running thread to the next, this is called as the context switch.
Correct Answer: True
Your Answer: True

Multiple Choice Multiple Answer
Question: Which one does not extend java.lang.Number?
Correct Answer: Boolean , Character
Your Answer: Integer , Boolean , Character

Multiple Choice Single Answer
Question: If you do not implement all the methods of an interface
while implementing, what specifier should you use for the class ?
Correct Answer: abtract
Your Answer: abtract

True/False
Question: Running threads can be suspended, which temporarily
suspends its activity.
Correct Answer: True
Your Answer: True

Multiple Choice Single Answer
Question: What are the possible access modifiers while implementing
interface methods?
Correct Answer: public
Your Answer: public

Java Programming - 13

LIST OF ATTEMPTED QUESTIONS AND ANSWERS

Multiple Choice Multiple Answer
Question: When might your program wish to run the garbage collector?
Correct Answer: When it knows there will be some idle time , Before it enters a compute-intense section of code , Before it enters a memory-intense section of code
Your Answer: Before it enters a memory-intense section of code , When it knows there will be some idle time , Before objects are finalized

Match The Following
Question Correct Answer Your Answer
start( ) thread main
main thread child thread child thread
NewThread this new
sleep( ) milliseconds milliseconds


Multiple Choice Multiple Answer
Question: Expression must be of the data types :-
Correct Answer: Byte , Short , Int
Your Answer: Byte , Int , Boolean

Multiple Choice Single Answer
Question: What are members of the threads class?
Correct Answer: Method
Your Answer: Method

Multiple Choice Multiple Answer
Question: What modifiers may be used with top-level class?
Correct Answer: Public , Abstract , Final
Your Answer: Public , Abstract , Final

Select The Blank
Question: Start( )executes a call to ________.
Correct Answer: run( )
Your Answer: run( )

Multiple Choice Single Answer
Question: What is a data structure that controls the state of a collection of threads as a whole?
Correct Answer: Thread group
Your Answer: Thread group

Match The Following
Question Correct Answer Your Answer
currentThread member of thread member of thread
High priority thread preemptive multitasking thread's priority
getName thread's name thread's name
isAlive thread is still running thread is still running

Multiple Choice Single Answer
Question: How do you assign values to variables?
Correct Answer: By using the assignment operator =.
Your Answer: By using the assignment operator =.

Multiple Choice Single Answer
Question: Which of the following is used to get the value of the instance variables?
Correct Answer: Dot Notation
Your Answer: Semi colon

Multiple Choice Multiple Answer
Question: Which are the keywords use in switch statement?
Correct Answer: Case , Default
Your Answer: Case , Default

Multiple Choice Multiple Answer
Question: The source for the frist package defines three classes
Correct Answer: Protection , Derived , SamePackage
Your Answer: Method , Derived , SamePackage

Multiple Choice Multiple Answer
Question: The Stack performs which two function?
Correct Answer: pop( ) , push( )
Your Answer: pop( ) , push( )

Select The Blank
Question: ________ variables are declared by use of the Byte Keyword.
Correct Answer: Byte
Your Answer: Byte

Select The Blank
Question: The ________ repeats a set of code at least once before the condition is tested.
Correct Answer: Do-while loop
Your Answer: Do-while loop

Multiple Choice Single Answer
Question: What is a string?
Correct Answer: A combination of characters called as string
Your Answer: A combination of characters called as string

Multiple Choice Single Answer
Question: How multidimensional array is declared?
Correct Answer: int[4] [5];
Your Answer: int[4] [5];

Multiple Choice Single Answer
Question: A thread name can be obtained by caling which method?
Correct Answer: getName( )
Your Answer: getName( )

True/False
Question: A thread can voluntarily relinquish control.
Correct Answer: False
Your Answer: False

Multiple Choice Single Answer
Question: Which cast must be used to convert a larger value into a smaller one?
Correct Answer: Explicit cast.
Your Answer: simplific cast

Multiple Choice Multiple Answer
Question: Modulus operator % can be applied to these data types :-
Correct Answer: floating Point , Integer , Character
Your Answer: floating Point , Integer , Character

True/False
Question: Suppose a given instance variable has been declared private, this instance variable is manipulated by methods outside its class.
Correct Answer: False
Your Answer: False

True/False
Question: Integer can Cast to byte value.
Correct Answer: False
Your Answer: True

Multiple Choice Single Answer
Question: How many concrete classes can you have inside an interface?
Correct Answer: none
Your Answer: three

Multiple Choice Single Answer
Question: When java program starts up, which thread begins running immediately?
Correct Answer: Main thread
Your Answer: Main thread

Multiple Choice Single Answer
Question: Which operator is used to create and concatenate string?
Correct Answer: Addition operator(+).
Your Answer: Addition operator(+).

Select The Blank
Question: After calling start( ) NewThread, constructor returns to ________.
Correct Answer: main( )
Your Answer: main( )

Multiple Choice Single Answer
Question: How to change the values of the elements of the array?
Correct Answer: By using array subscript expression
Your Answer: By specifying index number

Multiple Choice Single Answer
Question: How can class be imported from a package to a program?
Correct Answer: import java.packagename.classname
Your Answer: import java.packagename.classname

True/False
Question: Is it necessary to implement all the methods of an interface while implementing the interface
Correct Answer: False
Your Answer: False

Multiple Choice Single Answer
Question: A Java application can execute anywhere on the network, this implements that Java is :-
Correct Answer: Architecture neutral
Your Answer: Architecture neutral

True/False
Question: Interface can be extended.
Correct Answer: True
Your Answer: True

Select The Blank
Question: A class can only inherit a single ________.
Correct Answer: Superclass
Your Answer: Superclass

Multiple Choice Multiple Answer
Question: Exit statement is optional in which loops in java?
Correct Answer: While , Do-while , For
Your Answer: While , Do-while , For

True/False
Question: Java allows loops to be nested.
Correct Answer: True
Your Answer: True

Multiple Choice Single Answer
Question: What is an array?
Correct Answer: It is value collection of same type of data type
Your Answer: It is value collection of same type of data type

Select The Blank
Question: ________ loop repeats a statement or block while its controlling expressions is true.
Correct Answer: While
Your Answer: Do-while

True/False
Question: A thread can be blocked when waiting for a resource.
Correct Answer: True
Your Answer: True

Select The Blank
Question: A ________ is declared by use of the class keyword.
Correct Answer: class
Your Answer: class( )

Select The Blank
Question: Double data type uses ________ to store a value
Correct Answer: 64 bits
Your Answer: 64 bits

Multiple Choice Multiple Answer
Question: Packages act as containers for :-
Correct Answer: Classes , Subordinate packages
Your Answer: Classes , Subordinate packages , Subclasses

Select The Blank
Question: The mechanism by which java frees the memory occupied by unused objects is ________.
Correct Answer: Garbage Collection
Your Answer: Garbage Collection

Select The Blank
Question: The explicit drop of an object reference by setting the value of a variable, whose data type is a reference type of ________.
Correct Answer: Null
Your Answer: Instance

Multiple Choice Single Answer
Question: How many types of literals are there?
Correct Answer: Number literals, character literals, boolean literals, string literals, etc.
Your Answer: Number literals, character literals, boolean literals, string literals, etc.

Multiple Choice Single Answer
Question: How array is defined?
Correct Answer: int arr[];
Your Answer: int arr[];

Multiple Choice Single Answer
Question: What are primitive data types?
Correct Answer: byte, short, int, long
Your Answer: byte, short, int, long

Multiple Choice Multiple Answer
Question: Which of the following is the declaration of an array of string objects?
Correct Answer: String[ ] s; , String [ ]s: , String[ s]: Your Answer: String[ ] s; , String [ ]s: , String[ s]: