• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

explain me the doubts 2

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. pg 340 of k&b says

The enhanced for loop assumes that, barring an early exit form the loop, you'll always loop through every element of the array.


what does it mean?

2. pg 254 says

object
|
throwable
/ \
Error Exception
How an interface can extend a class? throwable is an interface and object is a class?

3. pg 360 says

Each method must either handle all checked exceptions by supplying a catch clause or list each unhandled checked exception as a thrown exception


What does it mean?

4.pg 363

void doStuff() throws MyException{
try{
throw new MyException();
}
catch(MyException me){
throw me;
}
}
}


explanation given in pg362 for compile error and given in pg 363 under exam watch is variable. explain which is correct and if both how they differ?

5. pg 408 and pg 409, i cant understand the two explanation given for self test answers (Q 14 &15)

6. 481 "the greedy quantifier dois in fact read the entire source data and then works from backward" what is greedy quantifier what does this rule specify?

7. HOW CAN WE USE \n AS META CHARACTER

8. in StringBuffer class equals() is overridden or not?

9. Explain pg 498 the selftest coding for Q1.

10. compilation fails is equivalent to compiles with error ?

11. explain in pg 588

List<Animal> animals=new ArrayList <Animal>();
animals .add(new Cat());
animals .add(new Dog());


"so this part works with both arrays and generic collections-- we can add an instance of a subtype into an array or collection declared with a supertype. You can add Dogs and Cats to an Animal array(Animal[]) or an Animal collection."

what does it mean?

i am very poor in generics/collection part. i cant understand the explanation and examples in k&b in that part. please specify where can i find proper explanation as i frequently mix up with generics and wild cards. Can <?> come in declaration side i.e to left of =?
 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
11 questions...in one post often dampen the spirits of a enthusiastic rancher ....too many questions...

I will try answering a few...

1) quote:
--------------------------------------------------------------------------------
The enhanced for loop assumes that, barring an early exit form the loop, you'll always loop through every element of the array.
--------------------------------------------------------------------------------


What this means is that unless you have a break, or continue or exception inside the loop...the loop completes normally...which means it loops through all elements of the collection...

2) object
|
throwable
/ \
Error Exception

Here Object is the Almighty System Object....everything in java is a type of Object...that is why Java is strictly Object oriented...

3)Each method must either handle all checked exceptions by supplying a catch clause or list each unhandled checked exception as a thrown exception

Try not believing it...just code a method with a checked exception...go ahead and complie it...what happens...

The compiler complains..the compiler always checks for the checked exceptions and if you dont handle or declare them...he will keep complaining...so to pacify him you need to do what this statement says...its simply a Java rule.
The Exceptions chapter in K&B give many examples of this..

I will leave the rest of the questions for some one else...

Thanks,
Megha
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic