SCJP 2_1
1 / 45
Term:
Definition:
Show example sentence
Show hint
Keyboard Shortcuts
  • Previous
  • Next
  • F Flip card

Complete list of Terms and Definitions for SCJP 2_1

Terms Definitions
public class SunRoof{}public class SexAppeal{}public class ManualTransmission{}public class Vehicle{}public class Car extends Vehicle{ private SunRoof sr;}public class Mustang extends Car{ private SexAppeal sa; private ManualTransmission mt;}True or False True
is an array an object? yes
Can you widen and then box? No
can a final class be subclassed? no
Which exam watch is important? page 675
What is the output?static void a(int b){ b = 7;}public static void main(){ int c = 5; b(c); System.out.println(c);} 5
can a method have multiple var-args params? no
what access levels can classes have? public, default
true or false, a method-local inner class object can access private members of the class it's enclosed within true
Since the notify notifies only one thread waiting, how do you notify all the threads waiting? notifyAll()
import java.io.*;class MainClass { public static void main(String[] args) { Apple a = new Apple("red", 10, 20); System.out.println("before: " + a.color + " " + a.height + " " + a.weight); try { FileOutputStream fs = new FileOutputStream("Serialized a, f (pg470-471)
True or False? Any Java object that can pass more than one IS-A test can be considered polymorphic. True
can final methods be overidden in a subclass? no
For an example on how to use notifyAll, look at the ode on page 753
Given a Calendar object, how do you add 1 hour to it?Calendar c = Calendar.getInstance();// What goes here? c.add(Calendar.HOUR, 1);
To which of these can the synchronized and native modifier be applied?a.) variablesb.) classesc.) methods c pg45,46
T/F: The default constructor can have arguments. F(Ref: p. 133)
can the properties of a final obj be changed? yes
Every object in Java has a built-in _________. This lock comes into play when the object has ____________ code lock. Synchronized
What does the following Octal numbers equal in decimal:A. int x = 011B. int y = 010 A. 9B 8
T/F: A class can be declared with only public or default access T(p. 12)
what acess levels can an instance variable have? public, private, default, protected
A thread that has not started is said to be in the _______ state. When you call start(), it will change to be in the _________ state new, alive
What is the correct invocation to retrieve a reference to the physical device on which the JVM is running? Console c = System.console();(not Console c = new Console();)p. 457/458
When can a class access a default member variable in a class in another package? It can't (p. 36)
what is an enum? a list of constant values assigned to a type
Do you have to catch the IllegalMonitorStateException? why not? no, it's a non-checked exception
public class Dog extends Animal {  public void speak() {    System.out.println("Bark.");  }  public static void main(String[] args) {    Dog dog = new Dog();    dog.speak();  }}abstract class Animal implements AnimalInterface {  public void Compilation error because class Dog cannot override the final method "speak()" declared in class Animal. (pg 40)
Does an overriding method need to declare exceptions if the overridden method declares them? No!  An Overriding method doesn’t have to declare any exceptions that it will never throw, regardless of what the overridden method declares.   pg(106-107)
Assume you call a method that takes a refernce to an interface, but there is no concrete class that implements that interface, what do you do? argument-defined anonymous inner class. for an example look at page 679
What is an atomic operation? is when grouping more than one step into a block of code, where the steps inside the block should never be seperated. Such as checking account balance and withdrawing money
Given the following code: import java.util.regex.Matcher; import java.util.regex.Pattern; public class PatternMatching { public static void main(String[] args) { Pattern p = new Pattern(args[0]); Matcher m = p.matcher(args[1]); while(m.find()){ System a. There are no constructors in the Pattern API. If the instantiation of the Pattern variable was changed to: Pattern p = Pattern.compile(args[0]); then the code would compile and the answer would be d. (p. 499)
What are the JavaBean naming rules for non-boolean properties? Getter method prefix is 'get'.Setter method prefix is 'set'.(p. 9)
What must be present as the first call (implicitly or explicitly) in a constructor? this() or super()(Ref: p. 134)
So how do you protect the data? 1. Mark the variable private 2. Synchronize the code that modifies the variables
What are the two primary purposes of Java wrapper classes? 1) To provide a mechanism to wrap values in an object so that the values can be used for activities reserved for Objects such as the Collections API.2) To provide an assortment of utility functions for primitives.
In general, How are regex expressions processed? In general from left to right, and once a source's character has been used in a match, it cannot be reused.pg. 490
What is the result?Class Test { public static void main (String args[]){ int x; int y; setX(x); y = 2; System.out.println(x + y); } private static void setX(int x) { x = 5; }} Wont compile. Local varialbes must be initialized and x is never initialized before use. pg54
what are some properties of a final variable? - cant be reinitialized once assigned a value - can't refer to a diff object once assigned - must be initialized before constructor completes
Why is the code at the bottom of 742 still not thread-safe? Because removeFirst should be synchornized. the method removeFirst() is not synchronized. So names.size() is synchronized, and names.remove() is synchronized. But nothing prevents another thread from doing something else to the list in between those two calls. And that's where problems can happen
What do the find(), start() and group() methods of the Matcher class do? The find method turns on the reg ex engine and does some searching. It returns true if a match is found, and remembers the start position of the match. The starting position of the match can be obtained by calling start(). The matched data can be obtained via the group() method.(p. 499)
public abstract class Fruit { public String getCategory(){ return "Fruit"; }}public class Nana extends Fruit{ public String getCategory(){ return "Nana"; } Public static void main(String args []){ Nana nana = new Nana(); System.out.println(nana. This is not the correct way to use the super modifier. 
Can the schedule context switch while the thread is in an atomic operation? yes it can. But no other thread will enter the atomic operation until this thread is done with it and gives up the lock
public abstract class A {  abstract void foo();}class B extends A {  void foo(int I) { }}   T/F - This will compile. False - It is required for class B to implement method foo().  Class B won't compile because of this.  (pg 44)
The only way to access an inner class is through an instance of the _______ _________ outer class. Example: MyOuter mo = new MyOuter(); MyOuter.MyInner inner = mo.new MyInner(); For an example look at the middle of page 667.