"For every success of a man there will be a countless pain in his heart and that pain makes him a successful person in life"

When You are at the Peak of Concentration, You don't feel whether u r programming in C/C#/JAVA or any other, You just type the keys on keyboard and your sub-conscious mind does the rest...!

Myspace GlittersMyspace GlittersMyspace GlittersMyspace GlittersMyspace GlittersMyspace GlittersMyspace GlittersMyspace Glitters




 
   

SCJP Exam 4

   
 


 

 

Home

Guestbook

GALLERY

MySQL

C/C++ Interview Questions

C/C++ Test Paper 1

C/C++ Test Paper 2

C Tricky Snippets

C - Pointers

C - Functions

C - Iterations, Operators

Java Interview Questions

Java Fundamentals

Java FAQs

J2EE - FAQs

Java - Best Collection Ever

Java/J2EE Test 1

Java Test 2

Java Servlets - FAQs

SCJP 5.0 Syllabus

SCJP Exam 1

SCJP Exam 2

SCJP Exam 3

SCJP Exam 4

SCJP Exam 5

Relational Database Management Systems(RDBMS) Imp. Concepts

SQL Server - Interview Questions

SQL Server 2

Data Structures

OOPS - FAQs

Object Oriented Programming (OOP) Concepts

Operating Systems - FAQs

Operating System Concepts

Networking Concepts

UML - Quick Reference

VB - FAQs

Secrets About Windows Operating Systems

 


     
 

Mock Test 4

 

Question 1.

         Read this piece of code carefully

if("String".toString() == "String")
    System.out.println("Equal");
else
    System.out.println("Not Equal");


Answers
 

  1. the code will compile an print "Equal".
  2. the code will compile an print "Not Equal".
  3. the code will cause a compiler error.

Question 2.

         Read this piece of code carefully
 

if(" String ".trim() == "String")
    System.out.println("Equal");
else
    System.out.println("Not Equal");


Answers

  1. the code will compile an print "Equal".
  2. the code will compile an print "Not Equal".
  3. the code will cause a compiler error

Question 3.

Read the code below. Will be the result of attempting to compile and run the code below.
 

public class AQuestion
{
     public void method(Object o)
     {
         System.out.println("Object Verion");
     }

 public void method(String s)
 {
    System.out.println("String Version");
 }

 public static void main(String args[])
 {
     AQuestion question = new AQuestion();
     question.method(null);
 }

}

Answers

  1. The code does not compile.
  2. The code compiles cleanly and shows "Object Version".
  3. The code compiles cleanly and shows "String Version"
  4. The code throws an Exception at Runtime.


 


Question 4.

Read the code below. Will be the result of attempting to compile and run the code below.
 

public class AQuestion
{
     public void method(StringBuffer sb)
     {
         System.out.println("StringBuffer Verion");
     }

 public void method(String s)
 {
    System.out.println("String Version");
 }

 public static void main(String args[])
 {
     AQuestion question = new AQuestion();
     question.method(null);
 }

}

Answers

  1. The code does not compile.
  2. The code compiles cleanly and shows "StringBuffer Version".
  3. The code compiles cleanly and shows "String Version"
  4. The code throws an Exception at Runtime.


Question 5.

    Read the following code below.

public interface AQuestion
{
     public abstract void someMethod() throws Exception;
}

A Class implementing this interface should
 

  1. Necessarily be an abstract class.
  2. Should have the method public abstract void someMethod();
  3. Should have the method public void someMethod() which has to throw an exception which is a subclass of java.lang.Exception.
  4. Should have the method public void someMethod() which need not throw an Exception.


Question 6.

        An Interface can never be private or protected.

Answers

        True
        False

 


Question 7.

      A Vector class in jdk 1.2

  1. is public
  2. is final
  3. implements java.util.List
  4. is serializable
  5. has only One constructor


 


Question 8.

     A String Class

  1. is final
  2. is public
  3. is serializable
  4. has a constructor which takes a StingBuffer Object as an Argument


 


Question 9.
 

public interface AQuestion
{
     void someMethod();
}

The class which implements AQuestion
  1. Should have someMethod which must necessarily be public.
  2. Should have someMethod which could be "friendly" or public
  3. Should have someMethod which should not throw any checked exceptions.
  4. Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface defination


 


Question 10.
 

public class AQuestion
{

 private int i = j;
 private int j = 10;
 public static void main(String args[])
 {
      System.out.println((new AQuestion()).i);
 }

}


Answers

  1. Compiler error complaining about access restriction of private variables of AQuestion.
  2. Compiler error complaining about forward referencing.
  3. No error - The output is 0;
  4. No error - The output is 10;

 

 

 
 

 

 

Thank You.. Visit Again

This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free