Richard Boren

Ranch Hand
+ Follow
since Mar 01, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Richard Boren

Congratulations Chandra!!!



Richard
16 years ago
Thanks Bert and Cmbhatt.

Bert it was one of your replies regarding what was on the 1.5 exam that sparked my effort. It wasn�t a big deal I just printed the objectives from the link you gave and then penciled in the page numbers as I worked through the chapters up to chapter 5. Then I avoid studding by doing the remaining 5 chapters.

Benefit for me� I know the objectives. If only that was 37 of the test questions...

Richard
Don�t know if this will be of any use, but here you have it.
I did my best on accuracy.

Declarations, Initialization and Scoping
1.1 p. 10, 19, 636 (inner(637); method-local(644); Anonymous(647); Static nested (654))
1.2 p. 19, 116
1.3 p. 4, 24, 141, 176, 209
1.4 p. 4, 24
1.5 p. 99, 122, 237
1.6 p. 126

Flow Control
2.1 p. 316
2.2 p. 331
2.3 p. 371
2.4 p. 344
2.5 p. 344
2.6 p. 366

API Contents
3.1 p. 227, 412
3.2 p. 429
3.3 p. 443
3.4 p. 457
3.5 p. 471

Concurrency
4.1 p. 674
4.2 p. 690
4.3 p. 700
4.4 p. 718

OO Concepts
5.1 p. 82, 147
5.2 p. 94, 112
5.3 p. 165, 167 (self test answers)
5.4 p. 99, 126, 237
5.5 p. 86

Collections / Generics
6.1 p. 536
6.2 p. 522
6.3 p. 570
6.4 p. 570
6.5 p. 546

Fundamentals
7.1 p. 760, 776
7.2 p. 760
7.3 p. 203
7.4 p. 244
7.5 p. 760, 772
7.6 p. 176, 276

Richard


by John Stone

I can see only two new String objects created:



John I believe you are right. System.out.println() smartly uses StringBuilder (mutable).

Thanks for pointing that out.

Richard


by Jim Yingst

...correct version of this question used the following declaration for process():

public static <E extends Number> List<E> process(List<E> nums) {



FYI, I check my book (ISBN 0-07-225360-6) and it has the correct version.

Richard
I guess so. I did read this on www.oopsla.org "...the standard class libraries, also known as system classes,..." I assume java uses the API packages for -esa and -dsa.

Richard


by swarna,

...how many String objects and how many reference variables were created prior to the println statement?



Thanks Swarna.
I didn't read "prior" until you pointed out.

Richard


Posted by swarna

Regarding
System.out.println( s1 + � and � + s3 ) ;
" and " will surely be created in the string pool.
I do assume that �abc and � and �abc and xyz� would be created because of left associativity and since one of them is a reference, they would be created on the heap.



Why don't we count them when counting the number Strings created?

Richard
By system classes are they talking about the core API's?

Richard
Hi Vinay,

final int a = 1 ; // This is a compile time constant because "a" is declared and initialized at the same time so the compiler knows its value.

final int b ; // here "b" is declared, but not initialized so the compiler doesn't know its value.

b = 1 ; // The assignment of "b" value is not known until runtime because the value could change. You could do something like this �b = (someExpression) ? 1 : 2 ;� The value of "b" cannot be known by the compiler.

Hope this helps.

Richard
Hi All,

What exactly are the system classes?

K&B says the �java �ea or �da� switches without arguments will enable or disable assertions in all classes, except for the system classes.

The book also says �java �ea �dsa� will enable assertions in general, but disable assertions in system classes.

I�m not seeing why �dsa is needed since it looks like the only why to enable the system classes� assertions is with the �esa switch. Also in what scenario(s) would the system classes� assertions need to be enabled by anyone other than a developer developing a system class?

Thanks, Richard
Hi All,

Am I understanding this right?

The String-constant-pool is in heap memory.

String s = �abc� ;

Creates a String literal �abc� in the String-constant-pool with s referencing �abc�.


String s1 = �abc� ;

No new String literal is created. s1 is simple referred to the already existing �abc� in the pool.


String s2 = new String( �abc� ) ;

A new String object �abc� is placed on the heap. No new String literal �abc� is put in the pool since �abc� already exist. s2 references the String object �abc� on the heap, but not the String literal �abc� in the pool.


String s3 = new String( �xyz� ) ;

A new String object �xyz� is placed on the heap and a String literal �xyz� is put in the pool. s3 references the String object on the heap, but not the String literal in the pool.


String s4 = new String( �xyz� ) ;

Another, different, String object �xyz� is placed on the heap. The if ( s3 == s4 ) fails. Again no new String literal �xyz� is put in the pool since �xyz� already exist. s4 references the String object �xyz� on the heap, but not the string literal �xyz� in the pool.


One last thing. Why doesn�t, �System.out.println( s1 + � and � + s3 ) ; � create new Strings without references? Wouldn�t the following Strings be created? � and � for one String. �abc and � for a second String. �abc and xyz� for a third String.

Thanks,

Richard
Hi Vinay,

You should re-read K&B�s switch text.

You are right,
final int DAY_CREATED = (int)(System.currentTimeMillis()); is a runtime constant; however, switch(DAY_CREATED) is the switch�s expression. It only needs to evaluate to a char, byte, short, int or an enum�s value that can automatically cast to an int. It does not have to be a compile time constant. Actually you wouldn�t normally want a constant in the expression even though it is legal. As you have already proven.

It is the switch�s �case:� that must be a compile time constant and must evaluate to the same type as the switch's expression can use.

Try this:




Richard
I thought another use for private constructors was for code redundancy.

Like,



Hope this makes since. I�m in a hurry, got a job interview to go to.

Richard
There is a similar Self Test question in K&B 1.5 (p. 305).

I too would like to know any kind of trick to speed up the time needed to solve this kind of problem. I got the problem right, but it took at least 15 minutes. That�s with pencil, paper and no stress. I just tried it again watching the time and it still took me 8 minutes to solve. That�s 8 minutes to solve a problem I had solved not that long ago, maybe 5 days ago. If there�s more than one question like this on the exam I feel I am doomed.

Richard