This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Thomas Hauck

Ranch Hand
+ Follow
since Jun 07, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
7
Received in last 30 days
0
Total given
9
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Thomas Hauck

The following page discusses the concept of a foreign key.

Define Foreign Key

The following page discusses the concept of an inner join.

SQL Inner Join

The following page
checked and unchecked
exceptions,
contains a list of checked and unchecked exceptions.
The following page contains several diagrams along with an explanation for the
Mediator Pattern.
The following page discusses the topic of
JavaBeans Manifest File in Detail.

JavaBeans Manifest File
The following page contains several examples of
the Singleton Design Pattern used in the real world.

Singleton Design Pattern
The following page discusses
composite primary keys
http://www.relationaldbdesign.com/relational-database-analysis/module2/composite-primary-keys.php
within the context of relational database design.
Is the
Interface Map.Entry<K,V>
at
http://docs.oracle.com/javase/7/docs/api/java/util/Map.Entry.html

and
Set<Map.Entry<K,V>> entrySet()


at
http://docs.oracle.com/javase/7/docs/api/java/util/Map.html#entrySet()

the same as

2)


Set<Map.Entry<K,V>> entrySet()

at
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentHashMap.html


except number 2 is

a) thread safe and
b) synchronized ?

Question 1: Why is it for lines A and B, that the third character “Z” ,
(which should be mapped to the last %s) is not printed?

My assumption is that because arg_index
%1$s has been used on lines A and B,

the characters are shifted 1 to the right and character “Z” is not printed.

Question 2: Even though the format specifiers for positions 1 and 2 are interchanged on lines A and B, their output is the same.

It is not clear to me why this is happening.

Hi Bernhard,

This is a theoretical problem and I do not have access to a relational database to run the code.

If I could run the code and see the output I probably would not have posted the question here.

I am doing a walkthrough of the code on paper.

Question:
If we had called the method acceptChanges() on “line A”, would the correct output have been

58 89 42 115 124

-----
I am reviewing the order of operations for updating rows in a table using the methods of
CachedRowSet through the following example



“stm” is valid reference to a Statement.
Note: Consider the following table below 'mathematicians' representing
a snapshot of the 'mathematicians' table.
In this example, only the column ID is important and I was unable to format the table elegantly as in Word or HTML.
----------------------------------------------------------------------------------------------
ID | FName | LName | Birthday | Country
58 | Carl |Gauss | 1777-04-30 | Germany
89 | Bernhard | Riemann | 1826-09-17 | Germany
103 | Issac | Newton | 1642-12-25 | England
115 | Jacob | Bernoulli | 1655-12-27 | Italy
124 | Pierre | Laplace | 1749-03-23 | France
----------------------------------------------------------------------------------------------

Because the method acceptChanges() was not called on line A, the changes will not be applied to the data source,
and upon executing the select statement, the output will be

58 89 103 115 124

In this code, we have obtained a CachedRowSet by using the constructor of the CachedRowSetImpl class.
crs.absolute(3); moves the cursor of the CachedRowSet “crs” to the 3rd row.
crs.updateInt(1, 42); changes the 1st column value of the 3rd row from 103 to 42

Updating a CachedRowSet object is similar to updating a ResultSet object.
However, because the rowset is not connected to its data source while it is being updated,
it must take an additional step to effect changes in its underlying data source.
So after calling the suitable update method, we should call the acceptChanges() method to have updates written to the data source.
Therefore the existing ID values will be printed as the output.

Question:
If we had called the method acceptChanges() on “line A”, would the correct output have been

58 89 42 115 124

Please confirm.
I was reading that an Inner Class can extend an Outer class.

Question: Is this done automatically, or do you have to specify the "extends" keyword?


Even though the lines 1 and 2 below are syntactically different,
is there anything else going on behind the scenes?



What role does white space have for the regular expession
String rex = "\\bM|\\bc";
that is compiled using Pattern.compile(rex); ?

For the String rex above,
whether you use a white space before or after the | operator, changes the output.
See commented output below.

For the regular expression
rex = "\\bM|\\bc";
it checks for a "word boundary" around capital M and lower case c.


Question: What are the rules that govern whitespace for a regular expression using Pattern.compile?
Can it be said that when a class has 2 or more threads and the methods are not synchronized,
the output will be non-deterministic?
Meaning, everytime you run the program a different output will occur.

For the code below, synchronized methods are not used, and each execution of the program may result in a different output.