Exceptions, String, Wrapper - Things you need to learn

Moderator: admin

Post Reply
Online
admin
Site Admin
Posts: 7551
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
    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 » 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?

Online
admin
Site Admin
Posts: 7551
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?

Online
admin
Site Admin
Posts: 7551
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: 112
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?

Online
admin
Site Admin
Posts: 7551
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.

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

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

Post by flex567 » Tue Oct 30, 2018 10:40 am

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

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

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

Post by admin » Tue Oct 30, 2018 10:55 am

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

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

Post by flex567 » Tue Oct 30, 2018 11:17 am

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: No registered users and 9 guests