Exceptions, String, Wrapper - Things you need to learn

Moderator: admin

Post Reply
admin
Site Admin
Posts: 7451
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Exceptions, String, Wrapper - Things you need to learn

Post by admin » Mon Sep 03, 2012 6:51 am

1. Exceptions
In Study View tree, under "Study Refs" node, you will see an "ExceptionClassSummary" document. It lists and explains the exceptions that you need to know about.
(You may also download the document from here: http://enthuware.com/downloads/Exceptio ... ummary.pdf )
Briefly:
  • Throwable
    Error and
    Exception
    RuntimeException

    ArrayIndexOutOfBoundsException
    ClassCastException
    NullPointerException
    ExceptionInInitializerError
    StackOverflowError
    NoClassDefFoundError

    IllegalArgumentException
    IllegalStateException
    NumberFormatException
    AssertionError
2. Methods in String, you need to learn about
  • substring
    replace
    charAt
    indexOf
    length
    toLower/UpperCase
    compareTo
    equals
    equalsIgnoreCase
    contains
    endsWith
    startsWith
    valueOf
    trim
Almost all are very straight forward and their names tell you what they do.

StringBuilder/Buffer
  • All 4 constructors.
    append
    delete
    insert
    indexOf
    length
    replace
    reverse
    substring
All very straight forward methods.

3. Wrappers
  • equals
    toBinaryString, toHexString
    valueOf
    parseInt/Byte etc.
    toString
    equals/compareTo
4. ArrayList
  • add
    addAll
    remove
    removeAll
    sublist
    retainAll
    get
    contains
    clear
    size
Similar methods for HashSet as well. Make sure you understand how a Set (and HashSet) behave when you add duplicate elements. How it checks for duplicity.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

gparLondon
Posts: 63
Joined: Fri Oct 31, 2014 6:31 pm
Contact:

Re: Exceptions, String, Wrapper - Things you need to learn

Post by gparLondon » Thu Nov 27, 2014 1:27 am

1> Do we really have to know about set and its behavior?

2> What about ensureCapacity() method in ArrayList and StringBuilder/Buffer? Do we don't have to know about it? and the method capacity() is only there in StringBuilder/Buffer, but not in ArrayList.

3> There is a setLength() method only in StringBuilder/Buffer? Am I right?

4> Which is thread safe? String, StringBuilder, StringBuffer,Array, ArrayList?

admin
Site Admin
Posts: 7451
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Exceptions, String, Wrapper - Things you need to learn

Post by admin » Thu Nov 27, 2014 2:37 am

1. Yes.
2. Not a must but good to know.
3. Yes, but please check the JavaDocs for such questions because there could be a class that you are thinking about but I am not that has this method.
4. StringBuffer. Not sure what you mean by "Array". If you mean a regular array, there are no add/remove "methods" in an array. String is immutable so no question about anyone modifying it.
If you like our products and services, please help us by posting your review here.

toolforger
Posts: 38
Joined: Fri Nov 13, 2015 4:40 am
Contact:

Re: Exceptions, String, Wrapper - Things you need to learn

Post by toolforger » Sun Jan 31, 2016 6:59 am

Threading-wise, Java arrays with their element slots behave just like Java objects with public instance variables, so no, they are not thread-safe at all.

aar2416
Posts: 10
Joined: Mon Jan 02, 2017 9:41 am
Contact:

Re: Exceptions, String, Wrapper - Things you need to learn

Post by aar2416 » Mon Jan 02, 2017 1:41 pm

Which array functions we need to know for OCA se 7?

admin
Site Admin
Posts: 7451
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Exceptions, String, Wrapper - Things you need to learn

Post by admin » Mon Jan 02, 2017 10:24 pm

All. You need to read about all of the concepts about arrays. Follow any good book and read its chapter on arrays. That should be enough.
If you like our products and services, please help us by posting your review here.

aar2416
Posts: 10
Joined: Mon Jan 02, 2017 9:41 am
Contact:

Re: Exceptions, String, Wrapper - Things you need to learn

Post by aar2416 » Tue Jan 03, 2017 11:28 am

admin wrote:All. You need to read about all of the concepts about arrays. Follow any good book and read its chapter on arrays. That should be enough.
thanks

flex567
Posts: 84
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: Exceptions, String, Wrapper - Things you need to learn

Post by flex567 » Sat Oct 20, 2018 4:55 pm

Can you add what do we need to know about the Date API?

admin
Site Admin
Posts: 7451
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Exceptions, String, Wrapper - Things you need to learn

Post by admin » Sat Oct 20, 2018 10:01 pm

Classes: java.time.LocalDateTime, java.time.LocalDate, java.time.LocalTime, java.time.format.DateTimeFormatter, java.time.Period
1. Constructors, static methods (now/of/from), and atXXX that deal with the creation of above classes.
2. parsing dates to/from date/string objects.
3. comparison of dates

Not really possible to list all the method names here because there are too many of them. Check out the Javadoc or go through Section 12.3 of OCAJP8 Fundamentals book by Hanumant Deshmukh.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests