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

Wednesday, August 6, 2008

Java Programming - 12

LIST OF ATTEMPTED QUESTIONS AND ANSWERS

Select The Blank
Question: The most commonly used ________eger type is int.
Correct Answer: int
Your Answer: int

Select The Blank
Question: The Process by which one object acquires properties of another object is ________.
Correct Answer: Inheritence
Your Answer: Inheritence

Multiple Choice Single Answer
Question: The easiest way to create a thread is to create a class that implements which interface?
Correct Answer: Runnable
Your Answer: Runnable

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

Multiple Choice Single Answer
Question: Which statement is used inside the switch to terminate a statement sequence?
Correct Answer: Break
Your Answer: Break

Multiple Choice Single Answer
Question: Which statement is used to explicitly return from a method?
Correct Answer: Return
Your Answer: Return

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

Select The Blank
Question: Java defines ________ Primitive type of data.
Correct Answer: Eight
Your Answer: Eight

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

Multiple Choice Single Answer
Question: Java's which system allows a thread to enter a synhcronized method on an object, and then wait there until some other thread explicitly notifies it to come out :-
Correct Answer: Messaging
Your Answer: Run time

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

True/False
Question: At any time, a thread can be terminated.
Correct Answer: True
Your Answer: True

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

Multiple Choice Multiple Answer
Question: Features of Java applets are :-
Correct Answer: They can be transmitted over internet , Require java enabled web browser
Your Answer: They require web server for their operation , Require java enabled web browser , They are intelligent programs.

True/False
Question: When you write finalize() method for your class, you are overriding a finalizer inherited from a super class.
Correct Answer: True
Your Answer: True

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

Multiple Choice Multiple Answer
Question: The Bitwise Logical Operators are :-
Correct Answer: ^ , ^= , <<
Your Answer: ^ , ^= , <<

True/False
Question: Boolean values can be cast into any other primitive type.
Correct Answer: False
Your Answer: False

Multiple Choice Single Answer
Question: Which method is used to determine the class of an object?
Correct Answer: getClass( ) method
Your Answer: getClass( ) method

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

Select The Blank
Question: ________can be extended.
Correct Answer: Interface
Your Answer: Class

Multiple Choice Multiple Answer
Question: Which are the java's control statements?
Correct Answer: For , If , Switch
Your Answer: If , Switch , Continue , For

True/False
Question: There is no Global Variable in Java.
Correct Answer: True
Your Answer: True

Select The Blank
Question: After the new thread is created, it will not start running until you call its ________method.
Correct Answer: start( )
Your Answer: start( )

Match The Following
Question Correct Answer Your Answer
The Operators used in mathematical Arithmetic Operator Arithmetic Operator
Order in which operators are evaluated Order of precedence Order of precedence
Whether an expression is evaluated Associativity Associativity
left-to-right or right-to-left.
Java operator syntax for right (= operator;) (= operator;)
associativity

Multiple Choice Single Answer
Question: Which Control Statements enable program execution to repeat one or more statements?
Correct Answer: Iteration
Your Answer: Iteration

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: short s = 20; , byte b = 128; , double d = 1.4;

Multiple Choice Multiple Answer
Question: Within what Java provides many levels of protection to allow control over the visiblity of variables and methods?
Correct Answer: Classes , Subclasses , Packages
Your Answer: Classes , Subclasses , Packages

Multiple Choice Single Answer
Question: Syntax to declare a variable in java is :-
Correct Answer: type identifier [=value][,identifier[=value]…]
Your Answer: type identifier [=value][,identifier[=value]…]

Multiple Choice Multiple Answer
Question: What are the programming constructs?
Correct Answer: Sequential , Selection -- if and switch statements , Iteration -- for loop, while loop and do-while loop
Your Answer: Sequential , Selection -- if and switch statements , Iteration -- for loop, while loop and do-while loop

Multiple Choice Multiple Answer
Question: What are means of encapsulating and containing the name space and scope of variables and methods?
Correct Answer: Classes , Packages , Subclasses
Your Answer: Classes , Packages , Subclasses

Multiple Choice Single Answer
Question: Which statement checks at the beginning of a loop to see whether the next loop iteration should occur?
Correct Answer: While
Your Answer: While

Multiple Choice Multiple Answer
Question: What are the Logical operators?
Correct Answer: OR() , AND(&) , XOR(^)
Your Answer: OR() , AND(&) , XOR(^)

Multiple Choice Multiple Answer
Question: Which of the following assignments are valid?
Correct Answer: short s = 28; , double d = 2.3; , int I = '1';
Your Answer: float f = 2.3; , double d = 2.3; , int I = '1';

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

Select The Blank
Question: We can contruct a thread on any object that implements ________.
Correct Answer: Runnable
Your Answer: Runnable

True/False
Question: Java compiler stores the .class files in the path specified in CLASSPATH environmental variable.
Correct Answer: False
Your Answer: True

True/False
Question: User-defined package can also be imported just like the standard packages.
Correct Answer: True
Your Answer: False

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

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

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

Select The Blank
Question: Java virtual machine works as ________ for the the bytecode.
Correct Answer: Interpreter
Your Answer: Interpreter

Select The Blank
Question: The mechanism which binds together the code and data and keeps both safe is ________.
Correct Answer: Encapsulation
Your Answer: Encapsulation

True/False
Question: Object oriented programming organizes a program around processes acting on data.
Correct Answer: False
Your Answer: True

Multiple Choice Multiple Answer
Question: Which statements can be used with the java's loop?
Correct Answer: Jump , Continue , Break
Your Answer: Continue , Break , Not

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

Multiple Choice Single Answer
Question: What are the kinds of variables in Java?
Correct Answer: Instance, local, class variables
Your Answer: Instance, local, class variables

Java Programming - 11

LIST OF ATTEMPTED QUESTIONS AND ANSWERS

True/False
Question: Threads of equal priority must voluntarily yield control to their peers.
Correct Answer: True
Your Answer: True

Match The Following
Question Correct Answer Your Answer
The Operators used in Arithmetic Operator Arithmetic Operator
mathematical expressions
Order in which operators are Order of precedence Logical Operator
evaluated in expressions.
Whether an expression is Associativity (= operator;)
evaluated left-to-right or
right-to-left.
Java operator syntax for right (= operator;) Comparison Operator
associativity

Multiple Choice Single Answer
Question: What can be created by instantiating an object type thread?
Correct Answer: Thread
Your Answer: Method

Select The Blank
Question: ________method starts a threrad by calling its run method.
Correct Answer: start( )
Your Answer: start( )

Multiple Choice Single Answer
Question: How to declare an interface example?
Correct Answer: access class classname implements interface.
Your Answer: access interface name

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

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

Multiple Choice Multiple Answer
Question: Java Operators can be divided into these groups :-
Correct Answer: Arithmetic , Bitwise , Relational
Your Answer: Arithmetic , Bitwise , Relational

Multiple Choice Single Answer
Question: Which keyword is used to create an instance of a class?
Correct Answer: new
Your Answer: new method

Multiple Choice Single Answer
Question: What are the kinds of variables in Java?
Correct Answer: Instance, local, class variables
Your Answer: Integer, char, long

Multiple Choice Single Answer
Question: Java was developed at :-
Correct Answer: Sun Microsystems
Your Answer: Sun Microsystems

Select The Blank
Question: Java defines ________ Primitive type of data.
Correct Answer: Eight
Your Answer: Eight

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

Multiple Choice Multiple Answer
Question: Classes usually consist of two things such as :-
Correct Answer: Instance variable , Methods
Your Answer: Instance variable , Objects

Multiple Choice Multiple Answer
Question: The Bitwise Logical Operators are :-
Correct Answer: ^ , ^= , <<
Your Answer: & , ^

Match The Following
Question Correct Answer Your Answer
It can have only one of two Boolean type Boolean type
possible values
Float hightemp, lowtemp Float variable declarations Float variable declarations
Smallest int type Byte Byte
Floating point numbers are Real Numbers Real Numbers
also known as

Select The Blank
Question: A ________ is a subclass of itself.
Correct Answer: Class
Your Answer: Instance

Select The Blank
Question: In ________ statement the value of the expression is compared with each of the literal values in case statements.
Correct Answer: Switch
Your Answer: Switch

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

Select The Blank
Question: The ________ loop is java's most fundamental looping statement.
Correct Answer: While
Your Answer: While

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: Distributed

Select The Blank
Question: In ________ statement condition is true, then statement 1 is executed.
Correct Answer: If
Your Answer: If

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

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 , First thread

Multiple Choice Multiple Answer
Question: Which is a public static member of thread?
Correct Answer: currenthread( ) , mainthread( )
Your Answer: currenthread( ) , Staticthread( ) , runthread( )

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

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 , Object , Try

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 Multiple Answer
Question: Modulus operator % can be applied to these data types :-
Correct Answer: floating Point , Integer , Character
Your Answer: floating Point , Character , Boolean

Select The Blank
Question: The ________ loop repeats a set of statements a certain number of times until a condition is matched.
Correct Answer: For
Your Answer: If

Multiple Choice Single Answer
Question: Which statement has a the effect of "jumping out" of the switch statement?
Correct Answer: Break
Your Answer: Break

True/False
Question: By default, all program import the java.lang package.
Correct Answer: True
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: Break

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

Select The Blank
Question: ________ statement in java is conditional branch statement.
Correct Answer: If
Your Answer: Switch

True/False
Question: As abstract class must have at least one abstract method and others may be concrete or abstract.
Correct Answer: True
Your Answer: True

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

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: False

Multiple Choice Single Answer
Question: Which cast must be used to cast an object to another class?
Correct Answer: Specific cast.
Your Answer: simplific cast

True/False
Question: Byte can be Cast to Double Value.
Correct Answer: True
Your Answer: False

Multiple Choice Multiple Answer
Question: What are the programming constructs?
Correct Answer: Sequential , Selection -- if and switch statements , Iteration -- for loop, while loop and do-while loop
Your Answer: Selection -- if and switch statements , Iteration -- for loop, while loop and do-while loop , Loop

Multiple Choice Single Answer
Question: When can a constructor be called without specifying arguments?
Correct Answer: When there are no constructors for the class
Your Answer: When the name of the constructor differs from that of the class

True/False
Question: Variable in an interface are implicitly final and static.
Correct Answer: True
Your Answer: True

True/False
Question: Boolean data type have only Yes or No value.
Correct Answer: True
Your Answer: True

Multiple Choice Multiple Answer
Question: Which are the two threads of java?
Correct Answer: mainthread( ) , childthread( )
Your Answer: mainthread( ) , childthread( )

Multiple Choice Multiple Answer
Question: Within what Java provides many levels of protection to allow control over the visiblity of variables and methods?
Correct Answer: Classes , Subclasses , Packages
Your Answer: Classes , Packages , Variables

Multiple Choice Single Answer
Question: Which method is used to determine the class of an object?
Correct Answer: getClass( ) method
Your Answer: getClass( ) method

Java Programming - 10

LIST OF ATTEMPTED QUESTIONS AND ANSWERS

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

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

Multiple Choice Single Answer
Question: Which Control Statements enable program execution to repeat one or more statements?
Correct Answer: Iteration
Your Answer: Break

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

Select The Blank
Question: The ________ is similar to break, except that instead of halting the execution of the loop, it starts the next iteration.
Correct Answer: Continue
Your Answer: Exit

Multiple Choice Single Answer
Question: Which Control Statement allow the program to execute in a non-linear fashion?
Correct Answer: Jump
Your Answer: Selection

Multiple Choice Single Answer
Question: Which class can be extended?
Correct Answer: threadclass
Your Answer: threadclass

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

True/False
Question: Each class in java can have a finalizer method.
Correct Answer: True
Your Answer: True

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[ ]:

Select The Blank
Question: Java virtual machine works as ________ for the the bytecode.
Correct Answer: Interpreter
Your Answer: Compiler

True/False
Question: Constructors can be overloaded like regular methods.
Correct Answer: True
Your Answer: True

Match The Following
Question Correct Answer Your Answer
Methods Member of Class Member of Class
Stack First In, Last Out First In, Last Out
Class Object Oriented Programming Simple class
Object Instance of Class Instance of Class

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

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

Select The Blank
Question: The mechanism which binds together the code and data and keeps both safe is ________.
Correct Answer: Encapsulation
Your Answer: Encapsulation

True/False
Question: There is no Global Variable in Java.
Correct Answer: True
Your Answer: False

True/False
Question: Object oriented programming organizes a program around processes acting on data.
Correct Answer: False
Your Answer: False

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

True/False
Question: Threads priorities are not integers that specify the relative priority of one thread to another.
Correct Answer: False
Your Answer: True

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.class

True/False
Question: When for loop start the execution, the initialization portion of the loop is executed.
Correct Answer: True
Your Answer: True

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

Multiple Choice Multiple Answer
Question: Which are the java's control statements?
Correct Answer: For , If , Switch
Your Answer: For , If , Continue

Select The Blank
Question: The Process by which one object acquires properties of another object is ________.
Correct Answer: Inheritence
Your Answer: Inheritence

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

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

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: Java compiler.

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 , Type of object , Class

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

Multiple Choice Single Answer
Question: Which statement checks at the beginning of a loop to see whether the next loop iteration should occur?
Correct Answer: While
Your Answer: Do-while

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 using array subscript expression

Multiple Choice Multiple Answer
Question: What are means of encapsulating and containing the name space and scope of variables and methods?
Correct Answer: Classes , Packages , Subclasses
Your Answer: Classes , Packages , Subclasses

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

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

Select The Blank
Question: The smallest integer type is ________.
Correct Answer: Byte
Your Answer: Byte

Multiple Choice Single Answer
Question: class conditional { public static void main(String args[]) { int i = 20; int j = 55; int z = 0; z = i < j ? i : j; // ternary operator System.out.println("The value assigned is " + z); } } } What is output of the above program?
Correct Answer: The value assigned is 20
Your Answer: The value assigned is 20

Select The Blank
Question: Multiple inheritance in Java can be achieve by ________.
Correct Answer: Interface
Your Answer: Object

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

Select The Blank
Question: The range of Byte is ________
Correct Answer: (-128 to 127)
Your Answer: (-128 to 127)

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

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

Select The Blank
Question: The ________ statement defines a name space in which classes are stored
Correct Answer: Packages
Your Answer: New

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

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

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

Multiple Choice Multiple Answer
Question: Which statements can be used with the java's loop?
Correct Answer: Jump , Continue , Break
Your Answer: Jump , Continue , Break