core java

6
Suppose you create an Employee class and declare the class variable numberContract. You then create an instance of the Employee class - accountEmployee. Identify the lines of code you can use to access the class variable numberContract. (Please select ALL that apply) Select an answer *A. accountEmployee.numberContract = 10; B. Employee accountEmployee = new Employee(); *C. Employee.numberContract = 10; D. static intnumberContract; Given: String x = new String("xyz"); y = "abc"; x = x+y; How many String objects have been created? Select an answer A. 2 *B. 3 C. 4 D. 5 Which two are true? Select an answer A. A finalizer may NOT be invoked explicitly B. The finalize method declared in class Object takes no action C. super.finalize() is called implicitly by any overriding finalize method *..D. The finalize method for a given object will be called no more than once by the garbage collector Which of the following is/are legal method declarations? Select an answer A. protected abstract void m1(); B. static final void m1(){} C. synchronized public final void m1() {} D. private native void m1(); *E. ...All the options are correct The following cannot be abstract: (Please select ALL that apply) Select an answer *A. Constructors *B. Static methods *C. Private methods D. Interface methods Choose which definitions holds good for variables. Select an answer **A. Variables that are defined inside a method and are called local, automatic, temp, or stack variables B. Variables created when the method is executed are destroyed when the method is exited

Upload: shohan-ahmed

Post on 15-Jul-2015

2.108 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: CORE JAVA

Suppose you create an Employee class and declare the class variable numberContract. You then create an instance of the Employee class - accountEmployee. Identify the lines of code you can use to access the class variable numberContract.(Please select ALL that apply)

Select an answer*A. accountEmployee.numberContract = 10;B. Employee accountEmployee = new Employee();*C. Employee.numberContract = 10;D. static intnumberContract;

Given: String x = new String("xyz"); y = "abc"; x = x+y; How many String objects have been created?

Select an answerA. 2*B. 3C. 4D. 5

Which two are true?

Select an answerA. A finalizer may NOT be invoked explicitlyB. The finalize method declared in class Object takes no actionC. super.finalize() is called implicitly by any overriding finalize

method*..D. The finalize method for a given object will be called no more

than once by the garbage collector

Which of the following is/are legal method declarations?

Select an answerA. protected abstract void m1();B. static final void m1(){}C. synchronized public final void m1() {}D. private native void m1();*E. ...All the options are correct

The following cannot be abstract:(Please select ALL that apply)

Select an answer*A. Constructors*B. Static methods*C. Private methodsD. Interface methods

Choose which definitions holds good for variables.

Select an answer**A. Variables that are defined inside a method and are called local,

automatic, temp, or stack variablesB. Variables created when the method is executed are destroyed when the

method is exited

Page 2: CORE JAVA

C. Variables are created by the JVMD. Variables cannot be de-referencedE. None of the options are correct

Identify the correct signature of the main method.

Select an answerA. public static int main (String args[])B. public static void main (String args)*C. public static void main (String args[])D. public void main (String[])

How do you initialize a variable using a static initialization block?(Please select ALL that apply)

Select an answerA. Declare the variable within the classB. Enclose the single-line initializer within a try-catch blockC. Perform the initialization inside a constructor*D. Place the initialization code inside a static block

To move control to the start of next repetition, which statement should be used?

Select an answerA. While statementB. If-else statementC. Break statement*D. Continue statement

What is an array?

Select an answerA. An array is a method that stores a list of itemsB. An array is a class that stores a list of items*C. An array is an object that stores a list of itemsD. An array is a message that stores a list of items

Some exceptions can occur in a program, but do not prevent compilation if they are not handled or declared. Which events can cause such exceptions?(Please select ALL that apply)

Select an answer*A. A method tries to open a fileB. An application tries to create an array that has negative size*C. An index, such as an array, is out of rangeD. Any attempt to access the contents of a SQL database

Some exceptions can occur in a program, but do not prevent compilation if they are not handled or declared. Which events can cause such exceptions?(Please select ALL that apply)

Select an answerA. A method tries to open a fileB. An application tries to create an array that has negative sizeC. An index, such as an array, is out of range

Page 3: CORE JAVA

D. Any attempt to access the contents of a SQL database

Java technology supports two types of streams:(Please select ALL that apply)

Select an answer*A. Character*B. ByteC. ShortD. Float

A byte can be of what size?

Select an answer*A. -128 to 127B. (-2 power 8)-1 to 2 power 8C. -255 to 256D. Depends on the particular implementation of the Java Virtual machine

Question: 15 of 30lt043991enQ0109Which of the following are true?(Please select ALL that apply)

Select an answer*A. TheInputStream and OutputStream classes are byte-orientedB. The ObjectInputStream and ObjectOutputStream do not support

serialized object input and output*C. The Reader and Writer classes are character-orientedD. The Reader and Writer classes are the preferred solution to

serialized object output

When a Java program tries to divide by zero; the runtime will create and throw an object of Arithmetic Exception.

Select an answer*A. TRUEB. FALSE

a method with no access modifiers CAN be overridden by a method marked protected.

Select an answer*A. TRUEB. FALSE

Question: 18 of 30lt043991enQ0006The Vector class implements a growable array of objects.

Select an answer*A. TRUEB. FALSE

x=true; y=true; What is the result of x and y?

Page 4: CORE JAVA

Select an answer*A. TRUEB. FALSE

_____________ expressions are a way to describe a set of strings based on common characteristics shared by each string in the set. They can be used to search, edit, or manipulate text and data.

Select an answer*..A. PredefinedB. Interface

An object means, anything that can D25be seen or touched; material thing.

Select an answer*..A. TRUEB. FALSE

<p>Will this compile?</p> float f = 27.24f;

Select an answer*A. YesB. No

The main() method in java can be overloaded. State true or false.

Select an answer*A. TRUEB. FALSE

The user can also create her own exception classes by inheriting from the class Exception.

Select an answer*A. TRUEB. FALSE

Procedures with common functionality are grouped into modules.

Select an answer*A. TRUEB. FALSE

JVM is Platform Independent.

Select an answerA. TRUE*B. FALSE

Both the methods sleep and join throws Interrupted Exception.

Page 5: CORE JAVA

Select an answer..A. TRUEB. FALSE

A base class reference can be used to access the sub class methods.

Select an answerA. TRUE*B. FALSE

Which code segments, if included in an interface, would cause a compiler error?(Please select ALL that apply)

Select an answer*A. protected void selectShipmentType(int type);*B. public final void printShippingDetails();C. static final int MAX = 100;D. void printShippingDetails();

JVM stands for java virtual machine.

Select an answer*A. TRUEB. FALSE

Page 6: CORE JAVA

Select an answer..A. TRUEB. FALSE

A base class reference can be used to access the sub class methods.

Select an answerA. TRUE*B. FALSE

Which code segments, if included in an interface, would cause a compiler error?(Please select ALL that apply)

Select an answer*A. protected void selectShipmentType(int type);*B. public final void printShippingDetails();C. static final int MAX = 100;D. void printShippingDetails();

JVM stands for java virtual machine.

Select an answer*A. TRUEB. FALSE