This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Q's on my Exam Prep!  RSS feed

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a neophyte to Java, but seeking for better stature that's why I've decided to prepare for the SCJP 1.4 exam. Please help me with my questions. Thanks to you all in advance. God bless!
Q1. import book.*;
What does this wildcard import statement mean? That the compiler will search for all classes that will later be used and furthermore, includes the class files in my user-defined or default package so that there are no accessibility problems?
Q2.Can an abstract subclass extend from a concrete superclass?
Q3. short m1(){return (short) 42;}
Is the cast (short) required or optional?
Q4. If a subclass-in-the-same-package inherits a protected member, what happens to the member? Does the subclass also inherit it as 'protected'?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I believe that
1) Yep, wildcard statement in "import books.*" means that you will be able to use all classes from package books in your source file. Note that if you also have package named books.whateverbooks, it won't be included, that is, wildcard is not recurrsive.
2) I think yes.
3) I believe it is optional here... Try compiling it.
4) It also inherits it as protected as long as you tell the compiler to do so, that is, define the overidding method as protected as well. When you override a method, it's access modifier can stay the same, or be less restrictive. So, assuming method is called myMethod, in the subclass you can either have public myMethod(){} or protected myMethod(){}
Be warned that this is the 2nd day I am studying for SCJP...
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to follow up on Andris' answer to number 2, he is correct, you can create an abstract class by extending a concrete class.
Good luck!
 
K Ville
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, thanks, my fellah greenhorns here. I still have a lot of questions, but I forgot to bring my list with me. Hope to hear more from you again. Thanks!
 
K Ville
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another question, please.
Q: interface MyInterface1{
void foo();
}
interface MyInterface2{
int foo();
}
Is it true that an implementer class is NOT allowed to implement these interfaces together because both have methods that have the same signature but different return types?
Follow-up: Why can an interface declare that it throws an exception in its throws clause, yet its implementer is not obligated to declare it? If the implementing class is not required to declare it, is it now obligated to handle it in a try/catch?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!