Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Java Placement Paper Questions

Monday, April 19, 2010

Question Casting occurs commonly between numeric types

Answer True

 

Question When might your program wish to run the garbage collector?

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

 

Question What are members of the threads class?

Answer Method

 

Question Boolean data type have only Yes or No value.

Answer True

 

Question The ________ loop is java's most fundamental looping statement.

Answer While

 

Question In multithreaded program each part of such program is called :-

Answer Thread

 

Question Which of the following are mathematical Expressions?

Answer (+ +) , (+ =) , (- =)

 

Question A thread can be blocked when waiting for a resource.

Answer True

 

Question Each class in java can have a finalizer method.

Answer True

 

Question Which statement has a the effect of "jumping out" of the switch statement?

Answer Break

 

Question As abstract class must have at least one abstract method and others may be concrete or abstract.

Answer True

 

Question The argument to which specifies the delayperiod in milliseconds

Answer sleep( )

 

Question When java program starts up, one thread begin runing and it is called ________thread.

Answer main( )

 

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?

Answer The value assigned is 20

 

Question When for loop start the execution, the initialization portion of the loop is executed.

Correct Answer True

 

Question ________ variables are declared by use of the Byte Keyword.

Correct Answer Byte

 

Question Which cast must be used to cast an object to another class?

Correct Answer Specific cast.

 

Question Which are keywords in Java?

Correct Answer Extends , Synchronized , Sizeof

 

Question What are different data types in java?

Correct Answer char , double , byte

 

Question Java uses which system to store packages?

Correct Answer File system directories

 

Question Constructors can be overloaded like regular methods.

Correct Answer True

 

Question What are different modifiers?

Correct Answer Private , Protected , Final

 

Question After the new thread is created, it will not start running until you call its ________method.

Correct Answer start( )

 

Question The ________ repeats a set of code at least once before the condition is tested.

Correct Answer Do-while loop

 

Question ________ loop repeats a statement or block while its controlling expressions is true.

Correct Answer While

 

Question The Bitwise Logical Operators are :-

Correct Answer ^ , ^= , <<

 

Question The name of the new thread is specified by ________.

Correct Answer threadName

 

Question ________ is probably the least used java data type

Correct Answer short

 

Question How to change the values of the elements of the array?

Correct Answer By using array subscript expression

 

Question What is declared within the file that will belong to the specified pacakage?

Correct Answer classes

 

Question How many concrete classes can you have inside an interface?

Correct Answer none

 

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

 

Question A class is ________ for an objects in java.

Correct Answer Template

 

Question Anonymous classes be implemented in an ________.

Correct Answer Interface

 

Question When an object is referenced, it mean that it has been identified by the finalizer method for garbage collection.

Correct Answer False

 

Question Features of Java applets are :-

Correct Answer They can be transmitted over internet , Require java enabled web browser

 

Question Classes usually consist of two things such as :-

Correct Answer Instance variable , Methods

 

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

 

Question If the break statement is omited in switch statement, then execution will continue on into the next case.

Correct Answer True

 

Question Which are the two threads of java?

Correct Answer mainthread( ) , childthread( )

 

Question The ________ repeat a set of code while the condition is false.

Correct Answer While loop

 

Question Which of these lines of code will compile?

Correct Answer short s = 20; , char c = 32; , double d = 1.4;

 

Question What are means of encapsulating and containing the name space and scope of variables and methods?

Answer Classes , Packages , Subclasses

 

Question How is it possible to use few methods of an interface in a class?

Answer By declaring the class as abstract

 

Question Which statement will always execute the body of a loop at least once?

Answer Do

 

Read more...

Java Multiple Choice Questions and Answers

Wednesday, February 17, 2010

Which Control Statements allow the program to choose different paths of execution?

Selection

 

Which Control Statements enable program execution to repeat one or more statements?

Iteration

 

The switch statement does not require a break.

False

 

In Interface we need not use the keyword abstract for the methods.

True

 

What are the Logical operators?

OR(|) , AND(&) , XOR(^)

 

Byte can be Cast to Double Value.

True

 

Which thread is created automatically when the program is started?

Main thread

 

Nested if is less efficient then switch statement.

True

 

 ________ are stored in hierarchical manner.

Packages

 

The mechanism by which java frees the memory occupied by unused objects is ________.

Garbage Collection

 

When you implement an interface method, it must be declared as :-

Public

 

What are primitive data types?

byte, short, int, long

 

In While loop condition can be any Boolean expression

True

 

Long makes it useful when big ________ numbers are needed.

Whole

 

Which Control Statement allow the program to execute in a non-linear fashion?

Jump

 

With java Type Casts are checked at both compile-time and runtime.

True

 

Java defines two ways when instantiating an object, such as :-

Can implement the runnable interface , Can extend the thread class

 

The explicit drop of an object reference by setting the value of a variable, whose data type is a reference type of ________.

Null

 

What is a string?

A combination of characters called as string

 

What are the programming constructs?

Sequential , Selection -- if and switch statements , Iteration -- for loop, while loop and do-while loop

 

What can be created by instantiating an object type thread?

Thread

 

In ________ statement the value of the expression is compared with each of the literal values in case statements.

Switch

 

How to declare an interface example?

access class classname implements interface.

 

Integer can Cast to byte value.

False

 

Transient variable is variable that may not be serialized.

True

 

Using which keyword we can fully abstract a class?

interface

 

The ________ loop repeats a set of statements a certain number of times until a condition is matched.

For

 

There are ________ kinds of Floating point type

Two

 

By default, all program import the java.lang package.

True

 

What returns a reference to the thread in which it is called?

Method , Class , Object

 

Do while loop always executes its body at least once, because its conditional expression is at the bottom of the loop.

True

 

Which statements can be used with the java's loop?

Jump , Continue , Break

 

________ are containers for classes.

Packages

 

Java's multithreading system is built upon :-

Thread class , Its methods , Companion interface

 

The default encoding of objects supports the ________ of the classes.

Evolution

 

Which are the keywords use in switch statement?

Case , Default

 

A Java application can execute anywhere on the network, this implements that Java is :-

Architecture neutral

 

Boolean values can be cast into any other primitive type.

False

 

Which one does not extend java.lang.Number?

Boolean , Character

 

The smallest integer type is ________.

Byte

 

Which is a public static member of thread?

currenthread( ) , mainthread( )

 

Casting does not affect the original object or value.

True

 

Anything declared ________ can be accessed from anywhere within program.

Public

 

Which method is used to determine the class of an object?

getClass( ) method

 

Method definition has four parts, they are :-

Name of the method , Type of object , List of parameters

 

Object oriented programming organizes a program around processes acting on data.

False

 

What are the possible access modifiers while implementing interface methods?

public

 

Which statement defines a name space in which classes are stored?

package

 

Which statement is used to explicitly return from a method?

Return

 

There are two distinct types of multitasking. Which are those?

Process based , Thread-base

 

Exit statement is optional in which loops in java?

While , Do-while , For

 

 

Read more...

Java Questions asked in various Companies Placement Papers

Tuesday, January 26, 2010

Java's which system allows a thread to enter a synchronized method on an object, and then wait there until some other thread explicitly notifies it to come out :-

Messaging

 

Packages act as containers for :-

Classes, Subordinate packages

 

Threads priorities are not integers that specify the relative priority of one thread to another.

False

 

When java program starts up, which thread begins running immediately?

Main thread

 

Java provides built-in support for which programming?

Multithreaded

 

The ________ is similar to break, except that instead of halting the execution of the loop, it starts the next iteration.

Continue

 

When can a constructor be called without specifying arguments?

When there are no constructors for the class

 

The mechanism which binds together the code and data and keeps both safe is ________.

Encapsulation

 

________ is an instance of a class that implements the runnable interface.

thread

 

Expression must be of the data types :-

Byte , Short , Int

 

Java define eight simple types of data byte, short, int, long, char, float, double, boolean.

True

 

What modifiers may be used with top-level class?

Public , Abstract , Final

 

Syntax to declare a variable in java is :-

type identifier [=value][,identifier[=value]…]

 

________ statement in java is conditional branch statement.

If

 

Which statement used inside a set of nested loops, will only break out of the innermost loop?

Break

 

In ________ statement condition is true, then statement 1 is executed.

If

 

The source for the frist package defines three classes

Protection , Derived , SamePackage

 

Java compiler stores the .class files in the path specified in CLASSPATH environmental variable.

False

 

Interface can be extended.

True

 

________ is the logical construct upon which the entire java language is built.

Class

 

Is it necessary to implement all the methods of an interface while implementing the interface

False

 

Which loops can be nested in java?

While, Do-while, For

 

Float data type is useful when we need fractional values.

True

 

What all the run( ) method can do?

Can call other method, Declare variable

 

Variable in an interface are implicitly final and static.

True

 

Which of the following operators are used in conjunction with the this and super references?

The dot operator

 

The ________ keyword halts the execution of the current loop and forces control out of the loop.

Break

 

What is a data structure that controls the state of a collection of threads as a whole?

Thread group

 

By Providing the interface keyword, Java allows you to fully utilize the which aspect of polymorphism?

One interface, Multiple methods

 

For externalizable objects the ________ is solely responsible for the external format of its contents.

Class

 

Which are the java's control statements?

For , If , Switch

 

What are the kinds of variables in Java?

Instance, local, class variables

 

Java Operators can be divided into these groups :-

Arithmetic , Bitwise , Relational

 

What is an array?

It is value collection of same type of data type

 

Modulus operator % can be applied to these data types :-

floating Point , Integer , Character

 

Start( )executes a call to ________.

run( )

 

________ is an instance of the class.

Object

 

________method starts a threrad by calling its run method.

start( )

 

Read more...

Chitika

About This Blog

Followers

  © Blogger template The Professional Template II by Ourblogtemplates.com 2009

Back to TOP