Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"

Anu Reddy

+ Follow
since Feb 05, 2019
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anu Reddy

Charles O'Leary wrote:

Anu Reddy wrote:
As you alluded, the compiler has determined that there are no checked exceptions that must be (further) handled nor declared [including main()].  Thus, the compiler allows compilation.  You likely noticed that none of these method signatures declare exceptions, whereas performBackup() internally handles exceptions and does not elect to pass on any of its exceptions to its caller.

Thanks Charles. That makes sense.

Hi, I am following OCA/OCP practice tests book by Jeanne B and Scott S. I have a qn in Ch8 , qn 49.

The following program compiles and i'm wondering how. The main() does neither declares the checked exception in its signature nor handles it.
In such cases, the program gives compile error. Can someone please provide insight on what i'm missing here. Thanks!

I am confused about loop variables in different variations of the for loop. I'm following Scott Selikoff and Jeanne Boyarsky OCA study guide and practice tests books.
In code snippets 1 and 2 below, the loop variable is used differently. In (1), the for loop is using the updated value of i after decrementing it on line 5, whereas in (2) the for loop is not using the incremented value of i.
Can someone please explain the difference here. TIA.

1. Practice tests chapter 5 qstn 31

2.  Study guide Chapter 2 Review qn 9


I was working on review question 20 and came across this scenario.
According to the book, " the values in each case statement must be compile-time constant values of the same data type as the switch value" .
Though the switch value type is 'char' and the statement  'case 1' below has value type of int, the program is compiling without any errors. I was expecting it to give a compile error when it encounters case 1.  
What am i missing?  TIA !


I have a question regarding the following code snippet solution on page 59 ( ch 2):

              int x = 3;
     int y = ++x * 5 / x-- + --x ;
     System.out.println( "x is" +x );
                     System.out.println( "y is" +y );

According to table 2.1 Order of precedence, post-unary operators are applied first, followed by pre-unary.
But in the above example, the first x with pre-unary operator is incremented and returned to the expression.

What am i missing here? Can someone point me in the right direction please.