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.

Given:
1. public abstract class Shape {
2. private int x;
3. private int y;
4. public abstract void draw();
5. public void setAnchor(int x, int y) {
6. this.x = x;
7. this.y = y;
8. }
9. }


Which two classes use the Shape class correctly? (Choose two.)



A.     public class Circle implements Shape {
private int radius;
}
B.     public abstract class Circle extends Shape {
private int radius;
}
C.     public class Circle extends Shape {
private int radius;
public void draw();
}
D. public abstract class Circle implements Shape {
private int radius;
public void draw();
}
E. public class Circle extends Shape {
private int radius;
public void draw() {/* code here */}
}
F. public abstract class Circle implements Shape {
private int radius;
public void draw() {/* code here */}
}

A.    AB Wrong Right

B.    BE Wrong Right

C.    AC Wrong Right

D.    BD Wrong Right

E.    CE Wrong Right

Answer : BE

Explanation : In ans B , child class is a abstract class thats why it is not implementing any abstract property of Shape, and in ans E child class is normal class it implements abstract property of super class Shape.
Ans A is wrong because we should not use implaments keyword to to implement abstract class.

Ans C is also wrong because whenever you write 

Learn more problems on : Abstract

Discuss on this question

2.


Public class Foo{
public void m1( int value ){
assert 0 <= value;
System.out.println( "OK" );
}
public static void main( String[] args ){
Foo foo = new Foo();
System.out.print( "foo.m1( 1 ): " );
foo.m1( 1 );
System.out.print( "foo.m1( -1 ): " );
foo.m1( -1 );
}
}


Predict the output of code if it is assert enabled?

A.    OK Wrong Right

B.    OK OK Wrong Right

C.    OK then triggers an assertion error Wrong Right

D.    None of these Wrong Right

Answer : OK then triggers an assertion error

Explanation : assert expression1;
assert expression1 : expression2;
In each form, expression1 is the boolean-typed expression being asserted. The expression
represents a program condition that the developer specifically proclaims must be true during program execution. In the second form, expression2 provides a means of passing a String message to the assertion facility

Learn more problems on : Assertions

Discuss on this question

3.

HashMap can be synchronized by _______ ?

A.    Map m = Collections.synchronizeMap(hashMap); Wrong Right

B.    Map m = hashMap.synchronizeMap(); Wrong Right

C.    Map m = Collection.synchronizeMap(hashMap); Wrong Right

D.    None of the above Wrong Right

Answer : Map m = Collections.synchronizeMap(hashMap);

Explanation : HashMap can be synchronized by Map m = Collections.synchronizeMap(hashMap);

Learn more problems on : Collections

Discuss on this question

4.

class A{
public static void main(String[] args) {
try {
args = null;
args[0] = "test";
System.out.println(args[0]);
} catch (Exception ex) {
System.out.println("Exception");
} catch (NullPointerException npe) {
System.out.println("NullPointerException");
}
}
What is the result?

A.    test Wrong Right

B.    Exception Wrong Right

C.    Compilation fails. Wrong Right

D.    NullPointerException Wrong Right

Answer : Compilation fails.

Explanation : Whenever you write number of catch blocks, catch block with super class (Exception)should be always at the end. Because if you write first then rest of the catch blocks will not going to execute. If you write super class Exception first then rest of the exception type next then it will throw compile time error. So in our program NullPointerException should come first then Exception class.

Learn more problems on : Exceptions

Discuss on this question

5.

Is the below statement true?

"Only objects that support the java.io.Serializable or java.io.Externalizable interface can be read from streams"

(Choose correct one from multiple below)

A.    true Wrong Right

B.    false Wrong Right

C.    can't say Wrong Right

D.    none of the above Wrong Right

Answer : true

Explanation : Only objects that support the java.io.Serializable or java.io.Externalizable interface
can be read from streams

Learn more problems on : File

Discuss on this question

6.

Class Test1{
Public static void main(String args[]){
Integer i1=10;
Integer i2=10;
If(i1==i2){
System.out.println(“ same”); }
Else{
System.out.println(“not same”) ; }
If(i1.equals(i2)){
System.out.println(“meaning fully equal”) ;}
} }

A.    same not same meaning fully equal Wrong Right

B.    

same meaning fully equal not same     
Wrong Right

C.    same meaning fully equal   Wrong Right

D.    

not same

Wrong Right

Answer : same meaning fully equal  

Explanation : here i1 and i2 are not two different objects, i1 and i2 are just references and these two holds same value 10, == operator is used to check the reference is same or not and .equals is used to check content is same or not. Here both content and reference is same so ans is C

Learn more problems on : Final and Datatypes

Discuss on this question

7.

which has public static void main(), so it will throw runtime error. what will be the out put of following code ?

G.java

class F{
static void main(String args[]){
System.out.println(“G”);
}
}

class G{
static void main(String args[]){
System.out.println(“F”);
}
}

A.    compile time error Wrong Right

B.    run time error

Wrong Right

C.    F Wrong Right

D.    G Wrong Right

Answer : F

Explanation : here, in a single file we have declared two class which has main method. The name using which you will save that class will execute and display the output.you can write multiple main methods in java only in different class ,not in a single class.

Learn more problems on : Flow Control

Discuss on this question

8.

2. public Object m()
{
Object o = new Float(3.14F);
Object [] oa = new Object[l];
oa[0] = o; /* Line 5 */
o = null; /* Line 6 */
oa[0] = null; /* Line 7 */
return o; /* Line 8 */
}


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

A.    just after line 5 Wrong Right

B.    just after line 6 Wrong Right

C.    just after line 7 Wrong Right

D.    just after line 8 Wrong Right

Answer : just after line 7

Explanation : Option A is wrong. This simply copies the object reference into the array.
Option B is wrong. The reference o is set to null, but, oa[0] still maintains the reference to the Float object.
Option C is correct. The thread of execution will then not have access to the object.

Learn more problems on : Garbage Collections

Discuss on this question

9.

Interface pet{
Void eat();
}

Class dog implements pet{
Public void eat(){}
}

Class Beagle extends dog{
Public void eat(){}
}

Which of the following demonstrate the”program to an interface ” principle?

A.    class petfood{
public void go(Pet p){
p.eat();}}
Wrong Right

B.    class petfood{
public void go(dog p){
p.eat();}}
Wrong Right

C.    class petfood{
public void go(Beagle p){
p.eat();}}
Wrong Right

D.    class petfood extends pet {
public void go(Petfood p){
p.eat();}}
Wrong Right

Answer : class petfood{
public void go(Pet p){
p.eat();}}

Explanation : There is no explanation...

Learn more problems on : Interface

Discuss on this question

10.

class W{
Public static void main(String args[]){
Int i=10;
Method(i); }
Static void method(Object o){
System.out.println(“object”); }
Static void method(Number n){
System.out.println(“number”); }
}

A.    compile time error Wrong Right

B.    runtime error Wrong Right

C.    object Wrong Right

D.    number Wrong Right

Answer : number

Explanation : from main() method calling Method by passing 10 as parameter. For int values Number is a super class , so output is option d).. Object is a super class of all the different type of class not for primitives.

Learn more problems on : Objects and Collections

Discuss on this question

11.

class A{
Int I;
Static{
A a=new A();
System.out.println(a.i);
}
}

A.    compile time error Wrong Right

B.    compile time error Wrong Right

C.    runtime error Wrong Right

D.    no output Wrong Right

Answer : compile time error

Explanation : JVM will execute SIB first , it will display default value of i. then JVM will come to know that there is no main method so it will throw an exception.so ans b) is correct.

Learn more problems on : Static Concept

Discuss on this question

12.

What is the output for the below code ?


public class B {
public static synchronized void printName(){
try{
System.out.println("printName");
Thread.sleep(5*1000);
}catch(InterruptedException e){
}
}
public synchronized void printValue(){
System.out.println("printValue");
}
}
public class Test extends Thread{
B b = new B();
public static void main(String argv[]) throws Exception{
Test t = new Test();
Thread t1 = new Thread(t,"t1");
Thread t2 = new Thread(t,"t2");
t1.start();
t2.start();
}
public void run(){
if(Thread.currentThread().getName().equals("t1")){
b.printName();
}else{
b.printValue();
}
}
}

A.    print : printName , then wait for 5 seconds then print : printValue Wrong Right

B.    print : printName then print : printValue Wrong Right

C.    print : printName then wait for 5 minutes then print : printValue Wrong Right

D.    Compilation succeed but Runtime Exception Wrong Right

Answer : print : printName then print : printValue

Explanation : There is only one lock per object, if one thread has picked up the lock, no other thread can pick up the lock until the first thread releases the lock. In this case printName() is static , So lock is in class B not instance b, both method (one static and other no-static) can run simultaneously. A static synchronized method and a non static synchronized method will not block each other.

Learn more problems on : Threads

Discuss on this question

13.

What is the output for the below code ?
public class Test{
int _$;
int $7;
int do;
public static void main(String argv[]){
Test test = new Test();
test.$7=7;
test.do=9;
System.out.println(test.$7);
System.out.println(test.do);
System.out.println(test._$);
}
}

A.    7 9 0 Wrong Right

B.    7 0 0 Wrong Right

C.    Compile error - $7 is not valid identifier. Wrong Right

D.    Compile error - do is not valid identifier. Wrong Right

Answer : Compile error - do is not valid identifier.

Explanation : $7 is valid identifier. Identifiers must start with a letter, a currency character ($), or
underscore ( _ ). Identifiers cannot start with a number. You can't use a Java keyword as an identifier. do is a Java keyword.

Learn more problems on : Variables and Loops

Discuss on this question

14.

  What is the result of trying to compile and run the following code.
public final static void main(String[] args){
double d = 10.0 / -0;
if(d == Double.POSITIVE_INFINITY)
System.out.println("Positive infinity");
else
System.out.println("Negative infinity");
}

A.    output Positive infinity Wrong Right

B.    output Negative infinity Wrong Right

C.    Will fail to compile Wrong Right

D.    Runtime exception Wrong Right

Answer : output Positive infinity

Explanation : There is no such thing as a positive or negative zero.
Hence the result is always positive infinity.

Learn more problems on : Language Fundamentals

Discuss on this question

15.

What is the true about the bellow code
class Outer {
static class Inner { }
}

A.    Inner class can be accessed without having an instance of the outer class. Wrong Right

B.    .Inner class can't be accessed without having an instance of the outer class. Wrong Right

C.    Compile error Wrong Right

D.    None of the above Wrong Right

Answer : Inner class can be accessed without having an instance of the outer class.

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.