• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ap computer science help?

th3dumbguy

Senior member
im not taking the test myself but my friend is and he wants me to ask something so he can be sure so here it goes...

public interface A
public class B implements A
public class C extends B

which declarations are right

B thisC = new C();
A thisB = new B();
A thisA = new A();

which ones of those would work?

i know the first one works but does the 2nd and 3rd work?
 
Tell your friend to think about what an interface actually is.

Then tell your friend to think about what implements and extends means, and what concepts those words actually refer to. It's all in the book and will serve him much better to know WHY than it will for us to tell him.
 
Uh. In Java you can do all but the third. You cant do the third because you can't instantiate an interface.

interFace Pet{}
Animal implements Pet{}
Dog extends Animal{}


Animal dog = new Dog();
Pet myPet= new Animal();

those are legal.

I checked using:

Comparable test = new BigInteger("10");
Component test3 = new JFrame();

Comparable is an interface. and JFrame extends Component.
 
think of it this way...

public interface cars
public class Ford implements cars
public class F150 extends Ford

Ford F150=new F150();
Cars Ford=new Ford();
Cars Cars = new Cars();

The first two make intuitive sense. They're the ones that are right.

Some more concrete explanation:
The last one is wrong b/c you can't instantiate an interface.
The first one is fine b/c you're making a new 150 that's of type Ford, its superclass.
Same argument for why the second one is true.
 
alright thnx guys for the help. did anyone take it today? some of my friends said it was fairly easy and they were surprised i didnt take it.
 
I am in college now. So no AP for me. Actually I was homeschooled so I never took any AP tests. Why bother when I was taking college classes instead?
 
Originally posted by: shuan24
since when did AP computer science test over java? I was thinking it should be c or c++...

last year was the first year it was in java. before that it had been cpp for some time; it was pascal before then

but yeah the way the AP does java is just retarded...
 
Java makes more sense than C++. But it is kinda ridiculous to test only one language since people learn different ones.
 
Back
Top