click below
click below
Normal Size Small Size show me how
SCJP
Study Cards for SCJP
Question | Answer |
---|---|
A legal identifier can start with a number | False |
is this a legal identifier int _a; | True |
Is this a legal identifier int $_r; | True |
What is the limit to the number of characters an identifier can contain? | There is no limit |
Sun Java Beans Convention for Classes and Interfaces | First letter must be capitalized |
Sun Java Beans Convention for Method casing | camelCase and verb noun pairs |
Sun Java Beans Listener Naming Rules | addActionListener removeActionListener They must end with Listener and the type of listener must be passed as the argument to the method |
Sun Java Beans Property getter and setter Naming Rules | use getProperty() or setProperty() |
How many public classes can exist on a single java source file | One |
The name of the java source file must be equal to what? | The name of the public class if there is one, otherwise you can use any name. |
Name all possible access modifiers | default (or package access) public private protected |
Is it possible to declare a class as protected? | Yes, but only if it is an inner class. A regular class can not be declared protected or private. |
Will this code compile? interface Foo { int bar = 10;} class Zap implements Foo { public void go(){bar = 11;}} | No, variables declared in an interface are ALWAYS final |
Is this a valid variable declaration? strictfp double x = 0; | No, strictfp applies only to methods |
Is this a valid variable declaration? native double x = 0; | No, native applies only to methods. |
Will the following code compile? public class MyClass{ public abstract void beatIt(); } | No, a class that is not declared abstract can not have abstract methods. |
When a class extends an abstract class, what requisite must be fullfilled? | It must implement all of the abstract methods from its superclass (and the ones from the superclass' superclasses) |
What does it mean to declare a method abstract final? ie: abstract final void testIt(); | Nothing, it is illegal to mark a method abstract and final, their meaning is opposite. |
Can you declare a method abstract static ? | No. |
The transient and volatile modifiers can only apply to... | Instance variables. |
What access modifiers apply to classes (all types of classes)? | default and public to regular classes and protected and private to inner classes. |
Is it possible for an interface to have static methods? | NO |
is it possible for an abstract class to extend a non abstract class? public class Electronic{} abstract class Phone extends Electronic{} | Yes, it is possible. |
Is the following abstract method declaration valid: public abstract void doEat(); | Yes |
is the following abstract method declaration valid? private abstract void doEat(); | No, abstract methods can not be private, they can only be default, public or protected. |
What access modifiers are valid for an abstract method? | Only public and protected (and obviously default - no access modifier). Private is not allowed. |
Will the following code compile class Foo { public void jump() {}} class Bar extends Foo{ public void jump() throws Exception{} } | No, Bar is overriding jump() but it is throwing a broader Exception than the parent |