Monday, March 23, 2015

OCPJP7: IO & NIO Version 2

Tuesday, March 17, 2015

OCAJP7 Preparation: Copy from coderanch.com

This article is a copy of  Passed-OCAJP from coderanch forum

Hello All,

Yesterday I cleared the OCAJP7 certification with 90% score
I would like to share my experience here so that it benefits someone out there who has not yet taken the test. Proud to tell that i have learnt at least some small thing from all the topics discussed over here.

Resources used: Oracle Java Documents, Enthuware, Java Ranch forum.
Time spent: Four months

Oracle java Documents:
I came across this Oracle Java Documents link online when i was searching for the SE7 material, and i liked the way the concepts are explained here, it is very crisp and has topic wise explanation on the exam objectives. When i finished reading those lessons i really felt i need something to test my knowledge.
That is when i got to know about Enthuware, there were wonderful feedback about the software, liked the trial version and decided to buy it.
I purchased the software in Nov,2014 and later i got to know why people have given such a wonderful feedback about it.

Enthuware:
I began giving the tests. Now i would like to point out what not to do when using this software! Do not hurry and finish all the mock tests if you do not have a good progress! Your aim should be to score 80% in them because in most of the discussions here it is pointed out that if you are scoring 80 and above in Enthuware mocks you seem to mostly likely clear the exam with good scores.
I am pointing this out because i made this mistake these are my scores:

Test 1-12 November 2014-39%
Test 2-19 November 2014-59%
Test 3-26 November 2014-67%
Test 4-4 December 2014-64%
Test 5-11 December 2014-67%
Test 6-20 December 2014-71%
Last Day Unique-10 January 2015-74%

And i was not serious about how i wrote these exams, as far as i remember finished first four tests in 1 hour or so.
After my last day test only i started reading the discussions in this forum and understood am not yet ready for the test but already ran out of my mock tests
So please do not take these mock tests so easy and finish them off! For my own satisfaction rewrote the first two tests and passed them.

What to do if you have already committed the above mistake?? (Read below)

After this for few days i started reading all the topics discussed in this forum under OCAJP7 and trust me i learnt a lot of small tricky things here. There are very beautiful and nice explanations in this forum which makes you understand things better.
In one of the discussions (I do not remember the exact thread ) , someone talked about the Leitner mode in Enthuware and that is when i understood the purpose of it and this is one of the ways to go through all the questions at least once!
I made a maximum use of it by ensuring i do not have any questions in Unlearned or Level 1 category.
Though your memory helps you find the answer, you get used to the concepts very well. It gets into your mind.
And one more suggestion, Adding notes in the software really helps to revise on the day of the exam.

Enthuware has good supporting team, for all my queries i had always got response from them very quickly.

On the DAY of the exam:

Had a good night's sleep and in the morning revised my own notes and the notes i had taken in enthuware.
During the exam, I was left with twenty minutes and nine questions for review. Reviewed them in ten minutes and spent remaining time in checking other questions.

I would like to tell:
1.Do not finish off your mock tests in hurry, because this is the best way to evaluate your learning and progress.
2.Make full use of Enthuware.
3.All the best for those are going to take test, Be confident.

Finally i would like to thank all the volunteers here who are doing an amazing job by spending their time in solving the doubts of Greenhorns like me! Kudos Team!!
I would like to learn more and more from this forum. After a small break will start to prepare for OCPJP7!

OCPJP7 BASIC

Monday, March 16, 2015

Feed Back OCPJP7

Today I failed the test for the first try.

The biggest problem comes from:
  • Basic Java concepts from early chapters 1-3
  • String processing
  • IO & NIO & NIO2
Feedback on your performance is printed below. The report lists the objectives for which you answered a question incorrectly.
  • Check, delete, copy, or move a file or directory with the Files class
  • Construct abstract Java classes and subclasses
  • Create and use List, Set and Deque implementations.
  • Create top-level and nested classes
  • Develop code that implements "is-a" and/or "has/a" relationships
  • Develop code that uses try-with-resources statements (including using classes that implement the AutoCloseable interface)
  • Find a file with the PathMatcher interface
  • Format strings using the formatting parameters: %b, %c, %d, %f, and %s in format strings.
  • Identify code that may not execute correctly in a multi-threaded environment.
  • Identify when and how to apply abstract classes
  • Load a resource bundle in an application
  • Manage and control thread lifecycle
  • Operate on file and directory paths with the Path class
  • Overload constructors and other methods appropriately
  • Override methods
  • Read and write data from the console
  • Search, parse and build strings (including Scanner, StringTokenizer, StringBuilder, String and Formatter)
  • Search, parse, and replace strings by using regular expressions, using expression patterns for matching limited to: . (dot), * (star), + (plus), ?, \d, \D, \s, \S,  \w, \W, \b. \B, [], ().
  • Sort and search arrays and lists
  • Submit queries and read results from the database (including creating statements, returning result sets, iterating through the results, and properly closing result sets, statements, and connections)
  • Use JDBC transactions (including disabling auto-commit mode, committing and rolling back transactions, and setting and rolling back to savepoints)
  • Use streams to read from and write to files by using classes in the java.io package (including BufferedReader, BufferedWriter, File, FileReader, FileWriter, DataReader, ObjectOutputStream, ObjectInputStream, and PrintWriter)
  • Use virtual method invocation
  • Use wrapper classes, autoboxing and unboxing.
  • Write code that declares, implements, and/or extends interfaces

Saturday, March 14, 2015

OCPJP7 Concurrency

Thursday, March 12, 2015

OCPJP7 Thread

Monday, March 9, 2015

OCPJP7 IO & NIO2 Version 1

Saturday, March 7, 2015

OCPJP7 Localization

Thursday, March 5, 2015

OCPJP7 String Processing

1.    String.length()
       String[].length---->Array

2.    String.charAt(): start from 0
       String.concat()
       String.equalIgnoreCase()
       String.length()
       String.replace()
       String.substring(including_index, excluding_index): start from 0
       String.toLowerCase()
       String.toUpperCase()
       String.trim()
       String.toString()

3.    new StringBuilder(); default capacity 16 chars(16*16 bits)
       new StringBuilder("ab");
       new StringBuilder(int capacity);

4.    Following methods are not used in String!!!
       StringBuilder.append()
       StringBuilder.delete(inclusive, exclusive): start from 0
       StringBuilder.reverse()
       StringBuilder.replace(inclusive_index, exclusive_index, String str)
       StringBuilder.insert(offset from 0 to length, String str): start from 0,
       (runtime exception thrown if offset is out of current length)

5.    Searching
       Pattern p = Pattern.compile(target);
       Matcher m = p.matcher(source);
       while(m.find()) {
           System.out.println(m.start() + m.end() + m.group());
       }
     
       Target
        a. Metacharacter:         1) \d (0-9)
                                           2) \D (NOT \d)
                                           3) \s (\s,\t, \n, \r, \f)
                                           4) \S (NOT \s)
                                           5) \w (a-z, A-Z, 0-9, underscore)
                                           6) \W (NOT \w)

         b. Boundary Macthing: \b:  start from position of first Word character, after that record position when previous character is different with current one.
                                           \B:  (NOT \b)

         c. Range: [abc] or [a-f] or [afAF] (-is needed)

         d. Quantifiers:
                                 + one or more (greedy)
                                 * zero or more (greedy)
                                 ? zero or one (greedy)
                                 ^ negative
                                 +? one or more (reluctant)
                                 *? zero or more (reluctant)
                                 ?? zero or one (reluctant)
                                  . any one not null


6. Tokenizing:

    a) String[] tokens = source.split(tokenizing);
        for(String s: tokens) System.out.println(">" + s + "<")

    b) Scanner(default whitespace, usedelimiter(string) to set delimiter)
        Scanner s1 = new Scanner(source);
        s1.hasNext()
        s1.hasNextInt() (1.3 IS OKAY)
        s1.nextInt()
        s1.nextBoolean
        s1.next()

     c) StringTokenizer(default whitespace)
         StringTokenizer st = new StringTokenizer("source");
         st.countTokens()
         st.hasMoreTokens()
         st.nextToken()

7. System.out.println("\" \\"); ----> " \
    Source.split("\\."); search for period.

8. System.out.printf() == System.out.format()

9. %[arg_index$] [flags][width][.precision] conversion char

    flags: - left justify
             + include a sign (+/-)
             0 pad with zero
             ,  use locale-specific
             ( enclose negative numbers in parentheses )
    width:
    precision: (floating point)
    conversion : b|c|d|f|s  (Barring use of boolean, mismatch will get a run time exception)

10. System.out.printf("%d", 123.2);  ERROR!!!
      System.out.printf("%f", 123);      ERROR!!!
      System.out.printf("%b", 123.1);  GOOD!!!

Wednesday, March 4, 2015

OCPJP7 Assertion

OCPJP7 Exception Handling



  1. Closeable (Java 5) throws IOException

    AutoCloseable (Java 7) throws Exception

  2. Closeable extends AutoCloseable.

  3. try-with-resources : close when get out of the try block in reverse order.

  4. If more than one exception is thrown in a try-with-resources block

    All later exception will be added as suppressed.

  5. try {

    }catch(Exception 1 | Exception 2 e) {

    }

    There should be no subclass relationship between Exception 1 and Exception 2. Do not assign a new value to "e" in multi-catch.

  6. If exception throws in catch block or finally block, no suppressions happen.

    The last exception thrown get sent to the caller.

  7. If a method throws a exception in the declaration, it must be included in try catch block. Even if it is in the finally block.


  8. Try-with-resource Object must not have close method if that Object is declared in Try block.