Page 1 of 1
Exceptions, String, Wrapper - Things you need to learn
Posted: Mon Sep 03, 2012 6:51 am
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.
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Thu Nov 27, 2014 1:27 am
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?
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Thu Nov 27, 2014 2:37 am
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.
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Sun Jan 31, 2016 6:59 am
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.
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Mon Jan 02, 2017 1:41 pm
by aar2416
Which array functions we need to know for OCA se 7?
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Mon Jan 02, 2017 10:24 pm
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.
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Tue Jan 03, 2017 11:28 am
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
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Sat Oct 20, 2018 4:55 pm
by flex567
Can you add what do we need to know about the Date API?
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Sat Oct 20, 2018 10:01 pm
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.
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Tue Oct 30, 2018 10:40 am
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
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Tue Oct 30, 2018 10:55 am
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
-Paul.
Re: Exceptions, String, Wrapper - Things you need to learn
Posted: Tue Oct 30, 2018 11:17 am
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?