Monday, April 15, 2013

Online SCJP Simulator

SCJP Simulators are very useful to Virtualize the real exam scenario.

One of the best simulators are SCJP whizlabs simulator. Here you can find all the useful materials


Take Online SCJP Test. It is Very Helpful

http://scjptest.com/mock-test.xhtml

Tuesday, April 9, 2013

My Success Story about OCPJP 6 Programmer

I cleared OCPJP 6 on 20 sept 2012 with 95% (69 questions correct out of 72). I thought of sharing about the secret of my success.

How to prepare for SCJP 1.6

Let me tell you one thing, the exam is very very very easy. But what you need is to focus  on fundamentals. The exam  will test a lot about your understanding about fundamentals rather than API content. I will divide this section into 3 parts.

Part 1 : Books I have followed

Sun Certified Programmer for Java 6 Study Guide  by Kathy Sierra and BertBates. Publishers Tata McGraw-Hill. Price – Rs 525
I don’t know whether you believe or not I just followed this one wonderful book. The author has explained all the fundamentals in a crystal clear manner and you love reading the book.
I have made a small notes which I am planning to share with you guys Click here to view my notes.
Don’t try to cram java, try to understand the language and its fundamentals. Write small programs while you prepare, believe me this will help a lot.


Part 2 :  Time taken to prepare.

It took  me 3 months to prepare ( this is completely different from person to person) .But believe me if you really want to understand the underlying concepts of java and if you want to excel in the market atleast prepare for 2.5 months.

Part 3 : Website URLs / Softwares that  I have followed to practice SCJP.

Softwares
Whizlab SCJP 1.6 Simulator
LearnKey Master exam – (I got this software with Kathy sierra book. This was the toughest exam which I have practiced.
Website URL’s
http://faq.javaranch.com/view?ScjpMockTests
http://www.certcrunch.com/msg.php
http://www.irixtech.com/
http://www.onlinemockexams.com/
http://www.javablackbelt.com/
Any more doubts mail me to @ kalpesh.karad@gmail.com







Oracle Certified Java 7 Programmer Mocks

Java 7 Mock Exam Questions

 
-------------------------------------------------------------------------------------------
 
Que 1:
What is the result of compiling and running the following code?
 






public class Tester {
public static void main(String[] args) {
String str = "java";
StringBuffer sb = new StringBuffer("javachamp");
sb.insert(9, ".com");
str.concat("champ");
if (sb.length() < 6 || str.equals("javachamp")) {
System.out.print(sb);
}
sb.delete(2, 7);
System.out.print(sb);
}
}

Please choose only one answer:
A.
Javachamp.comjamp.com
B.jamp
C.  jamp.com
D.javachampjamp
E.jap

------------------------------------------------------------------------

Que 2:
What will be the Output?






public class InnerClassThis {

int x=10;

public void foo() {

System.out.println("Outer class");

}

public class ReallyInner {

public void foo() {

System.out.println("Inner class");

}

public void test() {

this.foo();

InnerClassThis.this.foo();

}

}

public static void main(String... args) {

InnerClassThis.ReallyInner i = new InnerClassThis().new ReallyInner();

i.test();

}

}


Please choose only one answer:


A. The code does not compile.

B. Inner class

C. Outer class

E.The code compiles but throws runtime exception

F.Outer class

 

--------------------------------------------------------------------

 
 


 
QUE.3

Which is true? (Choose all that apply.)



A. "X extends Y" is correct if and only if X is a class and Y is an interface

B. "X extends Y" is correct if and only if X is an interface and Y is a class 

C. "X extends Y" is correct if X and Y are either both classes or both interfaces


D. "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces


C is correct.
------------------------------------------------------------------------
QUE.4
 
Which method names follow the JavaBeans standard? (Choose all that apply.)
A. addSize

 
B. getCust

 
C. deleteRep

 
D. isColorado

 
E. putDimensions

 
 Ans
B and D use the valid prefixes 'get' and 'is'.
------------------------------------------------------------------------

QUE.5
Given:
1. class Voop {
2. public static void main(String[] args) {
3.     doStuff(1);
4.     DOsTUFF(1,2);
5. }
6. // INSERT CODE HERE
7.}
 
Which inserted independently at line 6 will compile(Choose all that apply.)
A. static void doStuff(int... doArgs) { }
B. static void doStuff(int[] doArgs) { }
C. static void doStuff(int doArgs...) { } 
D. static void doStuff(int... doArgs, int y) { }
E. static void doStuff(int x, int... doArgs) { } 
 
Ans.
 
A and E are valid argument sysntax

------------------------------------------------------------------------

QUE.6
 Given
 1. enum Animal {
2. DOG("woof"), CAT("meow"), FISH("burble");
3. String sound;
4. Animals(String s) { sound = s; }
5. }
6. class TestEnum {
7.     static Animal a;
8.     public static void main(String[] args) {
9.                System.out.println(a.DOG.sound + " " +a.FISH.sound);
10.     }
11.  } 

What is the result?
A. woof burble
B. Multiple Compilation errors
C. Compilation failes due to error on line 2
D. COmpilation failes due to error on line 3
E. COmpilation failes due to error on line 4
F. COmpilation failes due to error on line 9 

Ans. A is correct;enums can have constructers and variables.
----------------------------------------------------------------------------------------------

QUE.7
Given two files
1. package pkgA;
2. public class Foo {
3.     int a;
4.     protected int b = 6;
5.     public int c = 7;
6. }

3. package pkgB;
4. import pkgA.*;
5. public class Bar {
6.       public static void main(String[] args) {
7.       Foo f = new Foo();
8.       System.out.println(" " + f.a);
9.       System.out.println(" " + f.b);
10.     System.out.println(" " + f.c);
11.   }
12. }

What is the Result ?(Choose all that apply.)
A. 5 6 7
B. 5 followde by an Exception
C. Compilation failes with an error on line 7
D. Compilation failes with an error on line 8
E. Compilation failes with an error on line 9
F. Compilation failes with an error on line 10

Ans.
 






D and E are correct. Variable a has default access, so it cannot be accessed from outside the
package. Variable b has protected access in pkgA.

--------------------------------------------------------------------------------

QUE.8
Given
1. public class Electronic implements Device
            { public void doit() { } }
2.
3. abstract class Phone1
4.
5. abstract class Phone2 extends Electronics
            { public void doit(int x) { } }}
6.
 7. class Phone3 extends Electronic implements Device
             {public void doStuff( )  { } }
8.
9.  interface Device { public void doit();  }

What is the result? ()Choose all that apply.)
A. Compilation succeeds
B. Compilation failes with an error on line 1
C.Compilation failes with an error on line 3
D.  Compilation failes with an error on line 5
E. Compilation failes with an error on line 7
F.  Compilation failes with an error on line 9

-----------------------------------------------------------------------------

  QUE.9
  Given
4. class Announce {
5.      public static void main(String[] args)  {
6.      for(int__x=0;__x<3;__x++)  ;
7.      int #lb = 7;
8.      long [] x [5];
9.      Boolean []ba[];
10.    enum Traffic { RED, YELLOW, GREEN };
11.     }
12.   }









What is the result? (Choose all that apply.)
A. Compilation succeeds








B.Compilation fails with an error on line 6
C. Compilation fails with an error on line 7
D.Compilation fails with an error on line 8

E.Compilation fails with an error on line 9









F.Compilation fails with an error on line 10

Answer:

C, D, and F are correct. Variable names cannot begin with a #, an array declaration can’t
include a size without an instantiation, and enums can’t be declared within a method.



-----------------------------------------------------------------------------
 





 
QUE.10
Given
3. public class TestDays {
4.    public enum Days {  MON, TUE, WED}
5.    public static void main(String[] args)
6.        for (Days d : Days.values() )
7.         ;
8.        Days [] d2 = Days.values();
9.        System.out.println(d2[2]);
10.        }
11.    }

What is the result? (Choose all that apply.)
A. TUE
B. WED

C. The output is unpredictable
D. Compilation fails due to an error on line 4
E. Compilation fails due to an error on line 6
F. Compilation fails due to an error on line 8
G.Compilation fails due to an error on line 9
 








Answer:
B is correct. Every enum comes with a static values() method that returns an array

of the enum's values, in the order in which they are declared in the enum.


-----------------------------------------------------------------------------

QUE.11
Given.







4. public class Frodo extends Hobbit {

5. public static void main(String[] args) {

6. Short myGold = 7;

7. System.out.println(countGold(myGold, 6));

8. }

9. }

10. class Hobbit {

11. int countGold(int x, int y) { return x + y; }

12. }







What is the result?
A.13
B. Compilation fails due to multiple errors
C.Compilation fails due to an error on line 6
D. Compilation fails due to an error on line 7
E.  Compilation fails due to an error on line 11

 Answer:

D is correct. The Short myGold is autoboxed correctly, but the countGold() method

cannot be invoked from a static context.



--------------------------------------------------------------------------------------------------------

 QUE.12




Given:
public abstract interface Frobnicate { public void twiddle(String s); }
Which is a correct class? (Choose all that apply.)
A. public abstract class Frob implements Frobnicate {





public abstract void twiddle(String s) { }

}

 




B. public abstract class Frob implements Frobnicate { }


 




C.public class Frob extends Frobnicate {

public void twiddle(Integer i) { }

}

 





D.public class Frob implements Frobnicate {

public void twiddle(Integer i) { }

}

 




E.public class Frob implements Frobnicate {

public void twiddle(String i) { }

public void twiddle(Integer s) { }

}


 




Answer:

B is correct, an abstract class need not implement any or all of an interface’s methods.
E is correct, the class implements the interface method and additionally overloads the

twiddle () method.
----------------------------------------------------------------------------------