Guest | Sign in | Register

Sign in to LucentBlackBoard

E-mail Id
Password
Loading...

New Member to LucentBlackBoard?

Forgot Your Password?

Enter your registered e-mail address, your password will be sent to e-mail address.
Enter E-mail Id
Loading...

Time left :





Note:

1. Total number of questions : 15.

2. Time alloted : 20 minutes.

3. Each question carry 1 mark, no negative marks.

4. Click the 'Submit Test' button given in the bottom of this page to Submit your answers.

5. Test will be submitted automatically if the time expired.

6. Don't refresh the page.

Result and Statistics

Time Left :

Result and Statistics ( Test No : online_test_number )

A. Number Of Question

15

B. Number Of Attempted

-

C. Number Of Correct Answer

-

D. Number Of Wrong Answer ( D = B-C )

-

E. Total Score ( E = C )

-

F. Accuracy Rate ( F = C / B * 100 )

-

G. Total Percentage ( G = C / A * 100 )

-



1.

interface Data { public void load(); }
abstract class Info { public abstract void load(); }


Which class correctly uses the Data interface and Info class?

 public void load() {

/*do something*/ 
}
}
"/> A.    public class Employee extends Info implements Data {
 public void load() {
/*do something*/ 
}
}
Wrong Right

public void load() { 

/*do something*/
}
}
"/> B.    public class Employee implements Info extends Data {
public void load() { 
/*do something*/
}
}
Wrong Right

C.    

public class Employee extends Info implements {
Data public void load(){
/*do something*/
}
public void Info.load(){
/*do something*/
}
}
Wrong Right

public void Data.load(){

 /*do something*/ 
}
public void load(){
 /*do something*/ 
}
}
"/> D.    public class Employee implements Info extends Data {
public void Data.load(){
 /*do something*/ 
}
public void load(){
 /*do something*/ 
}
}
Wrong Right

 public void load(){ 

/*do something*/ 
}
public void Info.load(){
 /*do something*/ 
}
}
"/> E.    public class Employee implements Info extends Data {
 public void load(){ 
/*do something*/ 
}
public void Info.load(){
 /*do something*/ 
}
}
Wrong Right

Answer : public class Employee extends Info implements Data {

 public void load() {
/*do something*/ 
}
}

Explanation : whenever you want to use interface then use implements keyword, and during abstract class use extends keyword. Vice versa is not true.

Learn more problems on : Abstract

Discuss on this question

2.

Which of the following statement is true about the assert statement. Select the one correct answer. 

A.    If a Java class contains assert statements, then it must be compiled with -1.4 option.  Wrong Right

B.    When a program having assertions is run, -assertion option must be specified, otherwise the assertions get ignored.  Wrong Right

C.    A possible syntax of assert statement is assert logical_expression If logical_expression evaluates to true, the program generates an AssertionError.  Wrong Right

D.    The program terminates on its first AssertionError. Wrong Right

Answer : The program terminates on its first AssertionError.

Explanation : The option A is incorrect, as the Java compiler option is -source 1.4 . The option B is incorrect, as the runtime option is -ea or -enableassertions. If the logical expression evaluates to false, then the program generates an AssertionError, hence C is incorrect.

Learn more problems on : Assertions

Discuss on this question

3.

What is the output for the below code ?

public class Test {
public static void main(String... args) {
int [] index = new int[5];
System.out.println(index instanceof Object);
}
}

A.    true Wrong Right

B.    false Wrong Right

C.    Compilation fails with an error at line 3 Wrong Right

D.    Compilation fails with an error at line 4 Wrong Right

Answer : true

Explanation : An array is always an instance of Object

Learn more problems on : Collections

Discuss on this question

4.


1. try{
2. // some code here
3.} catch (NullPointerException e1) {
4. System.out.print("a");
5.} catch (Exception e2) {
6. System.out.print("b");
7.} finally {
8. System.out.print("c");
9.}

If some sort of exception is thrown at line 2, which output is possible?

A.    a Wrong Right

B.    b Wrong Right

C.    c Wrong Right

D.    ac Wrong Right

E.    abc Wrong Right

Answer : ac

Explanation : You can have any number of catch blocks, if exception is occurred from try, then it will check in immediate catch , if immediate catch block is able to handle then it will go inside that catch block. If not then it will go and check next available catch block. and finally will execute whether exception occurs or not. So answer is D).

Learn more problems on : Exceptions

Discuss on this question

5.

public class A {
public A() {
System.out.println("A");
}
}
public class B extends A implements Serializable {
public B() {
System.out.println("B");
}
}
public class Test {
public static void main(String... args) throws Exception {
B b = new B();
ObjectOutputStream save = new ObjectOutputStream(new FileOutputStream("datafile"));
save.writeObject(b);
save.flush();
ObjectInputStream restore = new ObjectInputStream(new FileInputStream("datafile"));
B z = (B) restore.readObject();
}
}

What is the output?

A.    A B A Wrong Right

B.    A B A B Wrong Right

C.    B B Wrong Right

D.    B Wrong Right

Answer : A B A

Explanation : On the time of deserialization , the Serializable object not create new object. So
constructor of class B does not called.
A is not Serializable object so constructor is called.

Learn more problems on : File

Discuss on this question

6.

Class F
{
Static void test(Byte I,Byte j){
System.out.println(“BByte”);
}
Static void test(byte …b){
System.out.println(“byte”);
}

Public static void main(String args[]){
byte s=10;
test(s,s);
}
}

A.    compile time error Wrong Right

B.    runtime error Wrong Right

C.    BByte Wrong Right

D.    byte Wrong Right

Answer : byte

Explanation : Here test(s,s) will call test(byte…b) because these two are of type primitive.where as test(Byte , Byte) is of type class so it will not get called.

Learn more problems on : Final and Datatypes

Discuss on this question

7.

class F
{
Static public void main(String args[])
{
System.out.println(“HI”);
}
}

A.    compile time error Wrong Right

B.    run time error Wrong Right

C.    HI Wrong Right

D.    no output Wrong Right

Answer : HI

Explanation : Here we have swaped static keyword and public access specifier, that doesn’t effect the execution but if you swap void and main it will throw an error. Normal execution , JVM will execute from main method and displays HI.

Learn more problems on : Flow Control

Discuss on this question

8.

void start() {
A a = new A();
B b = new B();
a.s(b);
b = null; /* Line 5 */
a = null; /* Line 6 */
System.out.println("start completed"); /* Line 7 */


When is the B object, created in line 3, eligible for garbage collection? 

A.    after line 5 Wrong Right

B.    after line 6 Wrong Right

C.    after line 7 Wrong Right

D.    There is no way to be absolutely certain. Wrong Right

Answer : There is no way to be absolutely certain.

Explanation : There is no explanation...

Learn more problems on : Garbage Collections

Discuss on this question

9.

interface moveable{
Void move();
Void stop();
}

Which is valid?

A.    Public class bicycle implements moveable{
Public void move(){}
}
Wrong Right

B.    Public class bicycle implements moveable{
void move(){}
void stop(){}
}
Wrong Right

C.    Public class bicycle extends moveable{
Public void move(){}
Public void stop(){}
}
Wrong Right

D.    Public class bicycle implements moveable{
Public void move(){}
Public void stop(){}
}
Wrong Right

Answer : Public class bicycle implements moveable{
Public void move(){}
Public void stop(){}
}

Explanation : There is no explanation...

Learn more problems on : Interface

Discuss on this question

10.

class W{
Static void method(int I,int j ){
System.out.println(“int”); }
Static void method(byte…b){
System.out.println(“byte”); }

Public static void main(String args[]){
byte i=10;
method(i,i); }
}

A.    compile time error Wrong Right

B.    runtime error Wrong Right

C.    int Wrong Right

D.    byte Wrong Right

Answer : int

Explanation : while calling method() from main() we are passing exactly two parameter as byte , as we are calling by passing only two so it will display int.

Learn more problems on : Objects and Collections

Discuss on this question

11.

class G{
Int I;
}

Class Manager{
Public static void main(String args[]){
System.out.println(G.i);
}
}

A.    compile time error Wrong Right

B.    0 and runtime error Wrong Right

C.    runtime error Wrong Right

D.    no output Wrong Right

Answer : compile time error

Explanation : here variable I is non-static ,this variable can not be accessed from static function main(), if you try it will throw an compile time error.

Learn more problems on : Static Concept

Discuss on this question

12.

What is the output for the below code ?


class A extends Thread{
int count = 0;
public void run(){
System.out.println("run");
synchronized (this) {
for(int i =0; i < 50 ; i++){
count = count + i;
}
notify();
}
}
}
public class Test{
public static void main(String argv[]) {
A a = new A();
a.start();
synchronized (a) {
System.out.println("waiting");
try{
a.wait();
}catch(InterruptedException e){
}
System.out.println(a.count);
}
}

A.    waiting run 1225 Wrong Right

B.    waiting run 0 Wrong Right

C.    waiting run and count can be anything Wrong Right

D.    Compilation fails Wrong Right

Answer : waiting run 1225

Explanation : a.wait(); put thread on wait until not get notifed. A thread gets on this waiting list by
executing the wait() method of the target object. It doesn't execute any further
instructions until the notify() method of the target object is called. A thread to call wait() or notify(), the thread has to be the owner of the lock for that object.

Learn more problems on : Threads

Discuss on this question

13.

What is the output for the below code ?

1. public class Test {
2. public static void main(String[] args){
3. byte b = 6;
4. b+=8;
5. System.out.println(b);
6. b = b+7;
7. System.out.println(b);
8. }
9. }

A.    14 21 Wrong Right

B.    14 13 Wrong Right

C.    Compilation fails with an error at line 6 Wrong Right

D.    Compilation fails with an error at line 4 Wrong Right

Answer : Compilation fails with an error at line 6

Explanation : int or smaller expressions always resulting in an int. So compiler complain about Type mismatch: cannot convert from int to byte for b = b+7; But b += 7; // No problem because +=, -=, *=, and /= will all put in an implicit cast. b += 7 is same as b = (byte)b+7 so compiler not complain.

Learn more problems on : Variables and Loops

Discuss on this question

14.

   What is the result that will be printed out ?
void aMethod()
{
float f = (1 / 4) * 10;
int i = Math.round(f);
System.out.println(i);
}

A.    2 Wrong Right

B.    0 Wrong Right

C.    3 Wrong Right

D.    2.5 Wrong Right

E.    25 Wrong Right

Answer : 0

Explanation : The result of 1/4 will be zero because integer
divion is carried out on the operands.
If you need to obtain a fractional value
you need to use either a float or double literal
as in 1F / 4F.

Learn more problems on : Language Fundamentals

Discuss on this question

15.

What is the output for the below code ?
class Outer {
static class Inner {
void go() {
System.out.println("Inner.go");
}
}
}
public class Test {
static class Inner1 {
void go() {
System.out.println("Inner1.go");
}
}
public static void main(String... args) throws Exception {
Outer.Inner bn = new Outer.Inner();
bn.go();
Inner1 in = new Inner1();
in.go();
}
}

A.    Comile fail because Inner1 in = new Inner1(); Inner class can't be accessed without

having an instance of the outer class
Wrong Right

B.    Inner.go Inner1.go Wrong Right

C.    Runtime Exception Wrong Right

D.    Runtime Exception Wrong Right

Answer : Inner.go Inner1.go

Explanation : Static Inner class can be accessed without having an instance of the outer class. This is like other static members.

Learn more problems on : Inner Classes

Discuss on this question

Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved 2012-2015 SoftLucent.