Exceptions, String, Wrapper - Things you need to learn

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

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

Exceptions, String, Wrapper - Things you need to learn

Post by admin »

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
    setLength
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 »

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: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

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 »

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 »

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

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

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

Post by admin »

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 »

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: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

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

Post by flex567 »

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

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

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

Post by admin »

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.

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

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

Post by flex567 »

Are these all the methods we need to know for the exam?

DATE API

LocalDateTime.now();
LocalTime.now();
LocalDate.now();

static LocalDateTime from(TemporalAccessor temporal)

LocalDate:

static LocalDate of( int year, int month, int dayOfMonth)
static LocalDate of( int year, Month month, int dayOfMonth)

LocalTime:

static LocalTime of( int hour, int minute)
static LocalTime of( int hour, int minute, int second)
static LocalTime of( int hour, int minute, int second, int nanoOfSecond)

withMonth
withDayOfMonth
withYear
withHour

atTime
atDate
atZone
now

static LocalDate parse(CharSequence text)
static LocalDate parse(CharSequence text, DateTimeFormatter formatter)


java.time.format.DateTimeFormat
ISO_DATE
ISO_TIME
ISO_DATE_TIME
ISO_LOCAL_DATE_TIME

Period:
static Period of( int years, int months, int days)
static Period ofDays( int days)
static Period ofMonths( int months)
static Period ofWeeks( int weeks)
static Period ofYears( int years)

parse

static Period ZERO

equals
isZero
isNegative

-----------------------
plusDays
plusWeeks
plusMonths
plusYears
minusDays
minusWeeks
minusMonths
minusYears

plus( long amountToAdd, TemporalUnit unit)
plus( TemporalAmount amountToAdd)
minus( long amountToSubtract, TemporalUnit unit)
minus( TemporalAmount amountToSubtract)

withMonths
withDayOfMonth
withYears

negated

DateTimeException

DateTimeFormatter

static ofPattern(String pattern)
static ofPattern(String pattern, String locale)

format(DateTimeFormatter dtf)
ofPattern

static DateTimeFormatter ofLocalizedDate(FormatStyle dateStyle)
static DateTimeFormatter ofLocalizedDateTime(FormatStyle dateTimeStyle)
static DateTimeFormatter ofLocalizedDateTime( FormatStyle dateStyle, FormatStyle timeStyle)
static DateTimeFormatter ofLocalizedTime( FormatStyle timeStyle)

FormatStyle.FULL
FormatStyle.MEDIUM
FormatStyle.SHORT
FormatStyle.LONG

equals(Object obj)
compareTo
isAfter/ isBefore / isEquals

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

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

Post by admin »

Wow...great effort. Yes, that should be it. Hope you haven't missed any ;) Unless you want me to verify that you haven't missed anything :D
-Paul.
If you like our products and services, please help us by posting your review here.

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

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

Post by flex567 »

I didn't verify, and the list could be refined a bit as well.
Maybe some of the methods are missing and I think some should be removed?

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 28 guests