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.

Which three of the following are true?
a).An abstract class cannot be instantiated
b) An interface can extend multiple interfaces
c) All methods in abstract class must be abstract
d) If a class B directly extends class A , then class B must implement all the abstract methods which are declared in class A
e) If concrete class C extends concrete class B, and B implements interface A , then all the methods from interface A can be invoked on an instance of C.

A.    A,B,C Wrong Right

B.    A,C,E Wrong Right

C.    A,B,E Wrong Right

D.    B,C,E Wrong Right

E.    B,D,E Wrong Right

Answer : A,B,E

Explanation : Option a) is true because abstract

Option b) is true. The interface always has public static abstract methods. Abstract methods of parent class should be implemented in child class 

Learn more problems on : Abstract

Discuss on this question

2.

Which of the following statements is true?

A.    It is sometimes good practice to throw an AssertionError explicitly. Wrong Right

B.    Private getter() and setter() methods should not use assertions to verify arguments. Wrong Right

C.    If an AssertionError is thrown in a try-catch block, the finally block will be bypassed. Wrong Right

D.    It is proper to handle assertion statement failures using a catch (AssertionException ae) block. Wrong Right

Answer : It is sometimes good practice to throw an AssertionError explicitly.

Explanation : Option A is correct because it is sometimes advisable to thrown an assertion error even if assertions have been disabled.
Option B is incorrect because it is considered appropriate to check argument values in private methods using assertions.
Option C is incorrect; finally is never bypassed.
Option D is incorrect because AssertionErrors should never be handled.

Learn more problems on : Assertions

Discuss on this question

3.

Which three form part of correct array declarations?
1. public int a [ ]
2. static int [ ] a
3. public [ ] int a
4. private int a [3]
5. private int [3] a [ ]
6. public final int [ ] a 

A.    1, 3, 4 Wrong Right

B.    2, 4, 5 Wrong Right

C.    1, 2, 6 Wrong Right

D.    2, 5, 6 Wrong Right

Answer : 1, 2, 6

Explanation : (1), (2) and (6) are valid array declarations.
Option (3) is not a correct array declaration. The compiler complains with: illegal start of type. The brackets are in the wrong place. The following would work: public int[ ] a
Option (4) is not a correct array declaration. The compiler complains with: ']' expected. A closing bracket is expected in place of the 3. The following works: private int a []
Option (5) is not a correct array declaration. The compiler complains with 2 errors:
']' expected. A closing bracket is expected in place of the 3 and
expected A variable name is expected after a[ ] .

Learn more problems on : Declarations and Access Control

Discuss on this question

4.

class A{
void display() throws IOException,FileNotFoundException {
System.out.println(“class A”); }
}
class B extends A {
void display() throws IOException, FileNotFoundException,NullPointerException {
System.out.println(“class B”); }
}
class Test {
Public static void main(String args[]){
B b=new B();
b.display(); }
}
Output?

A.    class A Wrong Right

B.    class B Wrong Right

C.    class A, class B Wrong Right

D.    compile time error Wrong Right

Answer : compile time error

Explanation : In the above program class A is super class and it is throwing two exceptions. In class B which is child class of A must throw less number of exceptions compare to A. If child class throws more number of exceptions compare to super then the program will not compile successfully.
So d) is correct.

Learn more problems on : Exceptions

Discuss on this question

5.

What will be the result of compiling and run the following code:
public class Test {
public static void main(String... args) throws Exception {
File file = new File("test.txt");
System.out.println(file.exists());
file.createNewFile();
System.out.println(file.exists());
}
}

A.    true true Wrong Right

B.    false true Wrong Right

C.    false true Wrong Right

D.    None of the above Wrong Right

Answer : false true

Explanation : creating a new instance of the class File, you're not yet making an actual file, you're just
creating a filename. So file.exists() return false. createNewFile() method created an actual
file.so file.exists() return true.

Learn more problems on : File

Discuss on this question

6.

Public class Manager{
Static final int all[]=new int[]{0};
Public static void main(String args[]){
System.out.println(all.length); } }

A.    0 Wrong Right

B.    null Wrong Right

C.    compile time error Wrong Right

D.    1 Wrong Right

Answer : 1

Explanation : Explanation:it is a normal flow of execution

Learn more problems on : Final and Datatypes

Discuss on this question

7.

public class While
{
public void loop()
{
int x= 0;
while ( 1 ) /* Line 6 */
{
System.out.print("x plus one is " + (x + 1)); /* Line 8 */
}
}
}


Which statement is true? 

A.    There is a syntax error on line 1. Wrong Right

B.    There are syntax errors on lines 1 and 6. Wrong Right

C.    There are syntax errors on lines 1, 6, and 8. Wrong Right

D.    There is a syntax error on line 6. Wrong Right

Answer : There is a syntax error on line 6.

Explanation : Using the integer 1 in the while statement, or any other looping or conditional construct for that matter, will result in a compiler error. This is old C Program syntax, not valid Java.
A, B and C are incorrect because line 1 is valid (Java is case sensitive so While is a valid class name). Line 8 is also valid because an equation may be placed in a String operation as shown.

Learn more problems on : Flow Control

Discuss on this question

8.

class A{
A(){
System.out.println(1);
} }
Class B extends A{
B(){
System.out.println(2);
}}
Class C extends B {
C(){
System.out.println(3);
Super();
} }

Class Manager{
Public static void main(String args[]){
C c=new C();
} }

A.    1,2,20 Wrong Right

B.    20,2,1 Wrong Right

C.    compile time error Wrong Right

D.    run time error Wrong Right

Answer : compile time error

Explanation : in main() method we are creating an object of class C by using C class constructor, in class C constructor super() keyword is there in second statement, but according to the rule super () must be in the first statement in the constructor body , so it will throw compile time error.

Learn more problems on : Inheritance

Discuss on this question

9.

interface A{
Int i=0;
}
interface B extends A{
Int i=1;
}
interface C extends B{
Int i=2;
}
Class Manager implements A
{
Int i=3;
Public static void main(String args[])
{
C c1=(C)new Manager();
System.out.println(c1.i);
}
}

A.    3 Wrong Right

B.    ClassCastException Wrong Right

C.    compile time error Wrong Right

D.    none of the above Wrong Right

Answer : ClassCastException

Explanation : Here a class Manager implements A which is an interface so it will not throw any compile time error, but while creating an object we are creating an object of manager and trying to store in an c1 variable which is of type C.actually manager is of type A not of type C.. So it will throw ClassCastException.

Learn more problems on : Interface

Discuss on this question

10.

Which of the following are valid calls to Math.max? 


1. Math.max(1,4) 
2. Math.max(2.3, 5)
3. Math.max(1, 3, 5, 7)
4. Math.max(-1.5, -2.8f) 

A.     1,2 and 4 Wrong Right

B.    2,3 and 4 Wrong Right

C.    1,2 and 3 Wrong Right

D.    3 and 4 Wrong Right

Answer :  1,2 and 4

Explanation : (1), (2), and (4) are correct. The max() method is overloaded to take two arguments of type int, long, float, or double.
(3) is incorrect because the max() method only takes two arguments.

Learn more problems on : java.lang.class

Discuss on this question

11.

Which interface does java.util.Hashtable implement?

A.    Java.util.Map Wrong Right

B.    Java.util.List
Wrong Right

C.    Java.util.HashTable Wrong Right

D.    Java.util.Collection
Wrong Right

Answer : Java.util.Map

Explanation : Hash table based implementation of the Map interface.

Learn more problems on : Objects and Collections

Discuss on this question

12.

4. Which two statements are equivalent?
1. 3/2
2. 3<2
3. 3*4
4. 3<<2

A.    1 and 2 Wrong Right

B.    2 and 3 Wrong Right

C.    3 and 4 Wrong Right

D.    1 and 4 Wrong Right

Answer : 3 and 4

Explanation : (1) is wrong. 3/2 = 1 (integer arithmetic).
(2) is wrong. 3 < 2 = false.
(3) is correct. 3 * 4 = 12.
(4) is correct. 3 <<2= 12. In binary 3 is 11, now shift the bits two places to the left and we get 1100 which is 12 in binary (3*2*2).

Learn more problems on : Operators and Assignments

Discuss on this question

13.

What is the output for the below code ?


class A implements Runnable{
public void run(){
System.out.println("run-a");
}
}
1. public class Test {
2. public static void main(String... args) {
3. A a = new A();
4. Thread t = new Thread(a);
5. t.start();
6. t.start();
7. }
8. }

A.    run-a Wrong Right

B.    run-a run-a Wrong Right

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

D.    Compilation succeed but Runtime Exception Wrong Right

Answer : Compilation succeed but Runtime Exception

Explanation : Once a thread has been started, it can never be started again. 2nd time t.start() throws
java.lang.IllegalThreadStateException.

Learn more problems on : Threads

Discuss on this question

14.

What is the output for the below code ?


public class A {
static{System.out.println("static");}
{ System.out.println("block");}
public A(){
System.out.println("A");
}
public static void main(String[] args){
A a = new A();
}}

A.    A block static Wrong Right

B.    static block A Wrong Right

C.    static A Wrong Right

D.    A Wrong Right

Answer : static block A

Explanation : First execute static block, then statement block then constructor.

Learn more problems on : Variables and Loops

Discuss on this question

15.

Identify the valid assignments.

1. float f = \u0038;
2. long L2 = 2L;
3. float f = 1.2;
4. char c = '/u004E';
5. byte b = 100;

A.    2,3,4 Wrong Right

B.    1,2,3,4 Wrong Right

C.    4,5 Wrong Right

D.    1,2,5 Wrong Right

Answer : 1,2,5

Explanation : 1 is correct because \u0038 is unicode for nbr 8.
3 is wrong because 1.2 is a double literal.
4. is a little sneaky perhaps. The
unicode escape character is incorrect

Learn more problems on : Language Fundamentals

Discuss on this question

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