SCJP Object Oriented Programming

Java Programming World, Inc.                                  Since 2005
java programming

    The contents of this page are intended for SCJP 1.4 exam (310-035). The Sun Certified Java Programmers Exam (SCJP) is the internationally recognized. This site includes java certification mock exams, practice tests, Frequently Asked Questions (faq), scjp2 study material and sample code created by a Sun Certified Java Programmer which makes java certification exam preparation very easy.

    Earning a sun certification provides a clear demonstration of the core java scjp skills. This page is devoted to Java programmer certification, the exam which is commonly known as SCJP. The page contains links to several excellent resources for sun certification java.

Resources for java certification SCJP exam. There are mock exams and other useful java links.

    For clearing SCJP tests you need to know the basics of core java. There are three variations in SCJP.
 

CX-310-025 for SCJP 1.2

Exam type            -       Multiple choice and short answer
Total Questions  -       59
Pass score           -       61% i.e. 36 of 69 questions must be answered

CX-310-035 for SCJP 1.4

Exam type            -       Multiple choice and short answer
Total Questions  -       61
Pass score           -       52% i.e. 32 of 61 questions must be answered

CX-310-055 for SCJP 1.5 / SCJP 5.0

Exam type            -       Multiple choice and short answer
Total Questions  -       72
Pass score           -       59% i.e. 43 of 72 questions must be answered

    SCJP  5.0  is the latest Entry Level Certification exam provided by SUN Microsystems. SCJP 5.0 is based up on J2SE 5.0. I recommend that u should choose J2SE 1.4 as it has more resources on the web. The fee is around $150. You can buy a Voucher online and take the test at any thompson optometric center (the voucher would be valid for 1 year using which you get 20% discount).

    The recommended scjp books that you need to follow are:

1. A Programmer's Guide to Java Certification
                                                                by Khalid Azim Mughal, Rolf Rasmussen

2. Sun Certified Programmer & Developer for Java 2 Study Guide (Exam 310-035 & 310-027)
                                                                Kathy Sierra and Bert Bates
 

Note: Below are some Useful Programming Resources. Please use <right-click> "Save Link as" for pdf and doc Files.

Java Links

Beginner Java Tutorial

JDBC Tutorial

Java Interview Questions

Sun Certification Material (SCJP)

scjp khalid mughal

A Programmer's Guide to Java Certification - by Khalid Mughal and Rolf Rasmussen - very very good ebook for the exam. This one contains detailed description, and explains IO, Threads, GC etc quite well.

Complete Java2 Certification Guide


This site provides all the information you would need to prepare for Suns Certification exam (SCJP2). It provides study material, sample questions for all the topics covered in the exam, a Certification FAQ, a mock exam, and links to many other related sites. 

 

SCJP Mock Test

QUESTION : 1

 What is the result of compiling and running this program?

      class Mammal{
         void eat(Mammal m){
         System.out.println("Mammal eats food");
         }
      }
      class Cattle extends Mammal{
         void eat(Cattle c){
         System.out.println("Cattle eats hay");
         }
      }

      class Horse extends Cattle{
          void eat(Horse h){
          System.out.println("Horse eats hay");
          }
      }
      public class Test{
        public static void main(String[] args){
          Mammal h = new Horse();
          Cattle c = new Horse();  
          c.eat(h);
        }
      }


1. prints "Mammal eats food" 
2. prints "Cattle eats hay" 
3. prints "Horse eats hay" 
4. Class cast Exception at runtime.

ANS : 1


    The method that will be called is the one
    from class Mammal. The reasons are quite obvious.


QUESTION : 2

 Comsider the following class hierarchy. 
1. interface A{
2. public void method1();
3. }
4. class One implements A{
5. public void method1(){
6. System.out.println("hello");
7. }
8. }
9. class Two extends One{}
10. public class Test extends Two{
11. public static void main(String[] args)
12. {
13. A a;
14. Two t = new Two();
15. a = t;
16. a.method1();
17. }
18. }
What will be the outcome on attempting to compile and run this ?

1. Compiles and runs printing out "hello".
2. Compilation error at line 16.
3. The compiler raises an objection to the assignment at line 15.
4. Throws a NoSuchMethodException at runtime.  

ANS : 1

    Object reference conversion is possible here.
    The old type which is class can be assigned 
    to an interface type as long as the class implements
    that interface.



QUESTION : 3
  What will happen if you try to compile and run this ?
 interface A{
 public void innerMeth();
 }
        public class Test {
   A a;
   int memVar = 1;
          void aMethod(){
                 a = new A(){
                 public void innerMeth(){
                 System.out.println(memVar);
                 } };
    }

           public static void main(String[] args){
            Test t = new Test();
             t.a.innerMeth();
            } 
          }



1. Compiler error.
2. NoSuchMethodException at runtime.
3. Compiles and runs printing 1
4. Throws a NullPointerException at runtime.

ANS : 4
     You will get a NullPointerException because the 
     inner class object gets assigned to the reference a 
     only after the aMethod() runs. You can prevent 
     the exception by calling t.aMethod() before the 
     inner anonymous class method is called.



QUESTION : 4

       What will happen if you try to compile and run this code.

         class Rectangle{
           public int area(int length , int width) {
             return  length * width; 
           }
          }

         class Square extends Rectangle{
            public int area(long length , long width) {
            return  (int) Math.pow(length ,2);
           }
         }
        class Test{
          public static void main(String args[]) {
           Square r = new Square();
           System.out.println(r.area(5 , 4)); 
          }   
        }


1. Will not compile.
2. Will compile and run printing out 20
3. Runtime error
4. Will compile and run printing out 25

ANS : 1

    This code will fail to compile because the 
    compiler cannot resolve the method call here.
         
  




QUESTION : 5
    
   What will be the result of attempting to compile and run this.

     class Base{}
     class Derived extends Base{}
     public class Test {
       public static void main(String[] args){
         Derived d = (Derived) new Base();
       }
     }


1. Will not compile
2. Compiles and runs without error.
3. Runtime error

ANS : 3



QUESTION : 6

   What will this program print out ?
      class Base{
        int value = 0;
        Base(){
        addValue();
        }
        void addValue(){
        value += 10;
        }
       int getValue(){
         return value;
       }
     }
    class Derived extends Base{
      Derived(){
       addValue();
      }
     void addValue(){
     value +=  20;
      }
    }
    public class Test {
      public static void main(String[] args){
          Base b = new Derived();
          System.out.println(b.getValue());
      }
    }


1. 10
2. 20
3. 30
4. 40

ANS : 4




QUESTION : 7

   Almost the same code as in the previous question. 
   The only difference is the methods are static now.
   What will it print now?
  
   class Base{
      static  int value = 0;
        Base(){
        addValue();
        }
    static void addValue(){
        value += 10;
        }
       int getValue(){
         return value;
       }
     }
    class Derived extends Base{
      Derived(){
       addValue();
      }
    static void addValue(){
     value +=  20;
      }
    }
    public class Test {
      public static void main(String[] args){
          Base b = new Derived();
          System.out.println(b.getValue());
      }
    }


1. 10
2. 20
3. 30
4. 40

ANS : 3





QUESTION : 8

     What is the result of attempting to compile and run this ?
      interface ITest{
           public void setVal();
      }
      public class Test {    
          private String a; 
          void aMethod(){
          final String b;
          ITest it = new ITest() {
               public void setVal(){
               a = "Hello";
               b = " World";
               }};
          it.setVal();
          System.out.println(a + b);
          }
          public static void main(String[] args) {
          Test t = new Test();
          t.aMethod();
          }
       }
  

1. Code will not compile
2. Run time error
3. Will compile and run printing "Hello"
4. Will compile and run without any output

ANS : 1



QUESTION : 9


   What is the result of attempting to compile and run this ?

         class Base{
              String s = "Base";
              String show(){
              return s;
              }
         }     
         class Derived extends Base{
              String s = "Derived";
              }
         public class Test {    
              void print(Base b){
              System.out.println(b.show());
              }
              void print(Derived d){
              System.out.println(d.show());
              }
              public static void main(String[] args){
              Test t = new Test();
              Base b = new Derived();
              t.print(b);
              }
         }


1. Code will not compile
2. Run time error
3. Will compile and run printing "Derived"
4. Will compile and run printing "Base"

ANS : 4




QUESTION : 10

   What is the result of attempting to compile and run this ?
    interface ITest{
     public void setVal();
    }
    public class Test {    
      private String a; 
      void aMethod(){
      final String b = " World";
      ITest it = new ITest() {
                   public void setVal(){
                   a = "Hello" + b;
                   }};
      it.setVal();
      System.out.println(a);
      }
      public static void main(String[] args) {
      Test t = new Test();
      t.aMethod();
      }
    }

  

1. Code will not compile
2. Run time error
3. Will compile and run printing "Hello World"
4. Will compile and run printing "Hello"

ANS : 3

Get in touch with me personally at  hemanthjava@gmail.com

OTHER SITES OF MINE

FRESHERS JOBS AND PLACEMENT PAPERS

VTU PROJECTS AND PROGRAMS

 

Projects

1. Java Graphics Editor

scjp mock exams

These Mock exams will get you started with some simple practice questions. Its a great way to begin your SCJP 1.4 training.

scjp testking

Mock Exam Engine

1. Marcus Green Mock Exam 1

2. Marcus Green Mock Exam 2

3. Marcus Green Mock Exam 3

4. Java Test

5. Mock

6. Java Quiz 1

7. Java Quiz 2

8. Java Certification Mock Exam

Eclipse Tutorials

1. eclipse1.doc : A Simple tutorial showing how to create a project and execute code.

2. eclipse2.doc :  Frequently used Settings an Eclipse user should take care.

3. eclipse3.rtf :  Eclipse keyboard Shortcuts.

Sun Certifications are well recognized in the developers' community. Perhaps one of the reasons why Sun Certifications are so popular is that the exams are generally viewed as fairly challenging.

SCJP: A Sun Certified Java Programmer uses J2SE technologies to demonstrate the programming competence on Java platform.

Bob's Java Programming World, Inc. is independent of Sun Microsystems. All Rights Reserved