SCJP 7
1 / 49
Term:
Definition:
Show example sentence
Show hint
Keyboard Shortcuts
  • Previous
  • Next
  • F Flip card

Complete list of Terms and Definitions for SCJP 7

Terms Definitions
can private members be inherited? no
types of exceptions checked and unchecked
can an abstract class be instansiated no
what is 'this.' refers to current object
Which is preferred?int[] x;or int x[]; int[] x;
Which of the following modifiers can not be applied to an instance variable?a.) staticb.) transientc.) abstractd.) nativee.) volatilef.) synchronized a,c,d,fpg52
can a class implementing an interface be abstract? yes
name the access levels public, protected, default, private
can a class implementing an interface declare any new checked exceptions for an implementation method? no
To see how to synchronize static methods look at the very end of page 737
In what order will the following happen?When the first line of the static main method creates an instance of the Child class:1) Parent’s Static Initialization blocks2) Child’s Static Initialization blocks3) Parent’s Initialization blocks4) Childs In Answer: 1,2,3,5,4,6Pg(234-237)
T/F: There can be multiple public classes per source code file. F(p. 11)
can an enm be declared inside a class? yes
can an enum be declared inside a meothd? no
How do you define regular inner classes? page 665
One key point to remember about wait, notify and notifyall is that they must be called from within a ___________ context. A thread can't invoke wait or notify on an object unless it owns the lock for that object synchronized
Which of the following are NON-valid characters for the first character of a legal Java identifier?a. numberb. letterc. underscored. percent character (%)e. currency character ($) a, d(p. 5)
True or False. Signed primitives have more possible negative values than positive values? True pg 50
who can access default memebers? classes in the same package
What does regular anonymous inner classes look like? look on page 673
Which of the previous methods should be guarded by try and catch blocks? sleep, wait, join,
Define the effects of the final modifier on A Class? A method? A variable? 1) Class cannot be subclassed.2) Method cannot be overridden.3) A final variable cannot reassigned once assigned.(pg. 59)(pg.
who can see a default class? classes in the same package
For a thread to call call wait() or notify(), the thread has to be the __________ of the ________ for that object owner, lock
Which of the following will compile?1) String random[][] = new String[9][]();2) Integer [] ints = new Integer [] {7,8,9};3) Integer [] ints2 = new Integer {7,8,9};4) Integer [] ints3 = {7,8,9};5) int [] bacon [] = new int [3][]{{4,7,2},{}};6) int $[]; only 2,41 – illegal ();3 – missing [];5 – cannot declare size when creating anonymous array6 – cannot assign char array to an int array7 – type Nissan can be assigned to type car, but arrays must be of the same dimension.8 – Not declare size when constructing anonymous arrayPg(231-234)
Put the following in order from smallest to largest in terms of bit size and how many bits for each?long, byte, int, short byte(8), short(16), int(32), long(64) pg50
T / F - The default constructor has the same access modifiers as the class. True.  (pg 136)
Why are anonymous classes called anonymous? because they don't have a name
Which points are important to look at? bottom of 739 and 740
  What is the output of the follwoing code?   String x = "test"; System.out.println( x.length); Will give a comiler error p437
What are the JavaBeans naming conventions for a boolean? Getter method prefix of 'get' or 'is'.Setter method prefix of 'set'.(p. 9)
what is a var-arg paramater a param tha accepts from zero to infinte num of args
How many types of inner classes are there? what are they? 4. Static, method-local, anonymous, and plain-old regular inner classes
When does the garbage collector run? The JVM decides when to run the garbage collector. One can request that it run through the code, but there are no guarantees that it will do so.(p. 256)
What is the result?public class Test { public static int x; public static final int y; public static void main (String args[]){ final Test test = new Test(); test.x=(6); test.y=(7); System.out.println(x + " " + test.y); }} Compilation error. A final variable must be initialized before the constructor completes.(pg. 57)
T/F: The following identifier is legal:int .f; False - Identifier does not start with a letter, currency char ($) or underscore.(Ref: p. 5)
How are static-inner classes different than plain-old inner classes? They can be accessed without having to instantiate an instance of the outer class. OuterClass.InnerClass n = new OuterClass.InnerClass(); Look at the code in the middle of 681
When a thread is created, what priority will be assigned to it? The priority of the thread that creates it
Which of the following statements about the java.util.Scanner class are true?a) Scanners can be constructed using files, streams, or Strings as a source.b) The default Scanner delimiter is a commac) Tokens can be converted into their primitive types autom a and cFor b, the default delimiter of the Scanner is whitespace. d is incorrect because the methods are hasNext, hasNextInt, hasNextBoolean, etc. (The Scanner class has nextXxx() methods for every primitive type except char). Regarding c, Scanner can convert tokens into their primitive types automatically by invoking the nextInt, nextBoolean, etc methods of the class.(p. 504/505)
Can a private method be overridden by a subclass? No, since the subclass cannot inherit from the superclass, it therefore cannot override the method.
Is this legal:public Button doStuff() { return null;} Yes, you may return null as an object reference return type. (p. 128)
What is needed to instantiate an inner class? To instantiate an inner class, an instance of the outer class is needed. There is no exception to this rule. an inner class instance can never stand alone without a direct relationship to an instance of the outer class
What happens when we enter a synchronized non-static method The lock for that specific instance is acquired
Can finalize() result in saving an object from deletion? Yes - in that method, one could write code that passes a reference to the object in question back to another object, effectively uneligibilizing the object for garbage collection.(p. 263)
Can you create a method in a subclass that has the same name as a private method in a superclass? Yes, if the superclass method is private then the subclass method can have the same name without compiler error.
True or False. A thread that has already started, can be started again. How about if it's done executing the run() method False and False. A thread that has been started can never be started again
What are the key interface and methods involved in serialization? 1. The class (or a parent class) must implement Serializable2. Invoke ObjectOutputStream.writeObject() on the object to serialize3. Invoke ObjectOutputStream.readObject() on the object to deserializep. 460
T/F: The constructor of a class must not have a return type. T(Ref: Question 7 in Mock Exam 1 for SCJP 6 at http://www.javaprepare.com/quests/test.html)
Is this legal?public class Foo { void go() { }}public class Bar extends Foo { String go() { return null; }} No. You can't change only the return type. To fix this, the 2nd go() method would have to be changed to either have: a) The same return type of void (i.e. match 1st go() method). This would make the code above an example of overriding. b) A different parameter list (note: no change to return type needed although one may be made). This would make the code above an example of overloading.(p. 127)