Sun Certified Java Programmer
1 / 95
Term:
Definition:
Show example sentence
Show hint
Keyboard Shortcuts
  • Previous
  • Next
  • F Flip card

Complete list of Terms and Definitions for Sun Certified Java Programmer

Terms Definitions
—unlike instance variables—local variables don't getdefault values.
Which code is important? 478
Tosummarize, which overridden version of the method to call (in other words, fromwhich class in the inheritance tree) is decided at runtime based on object type, butwhich overloaded version of the method to call is based on the reference type ofthe argume
Which exam watch is important 572
characters are just 16-bit unsigned integers under the hood. true
Which exam watch is important? page 441
The DateFormat and NumberFormat objects have their locale set during instantiation. How do you set them or reset them after instantiation? You can't
The Set interfaces cares about ________ Uniqueness
For examples of initialization blocks look at page... 234
Which example is important? top of 440
Ifthe variable is declared as an interface type, it can reference any object of anyclass that implements the interface.
and variables defined in the interface are declared. These rules are strict:■ All interface methods are implicitly public and abstract.
Can access modifiers be applied to local variables? No
LinedList implements two interfaces, which are they? List and Queue
Whenever you're done with a file, whether you're reading it or writing it, you should invoke _______ close()
If you have a class that's serializable, and this class has an instance of a class that's not serializable, attempting to serialize will cause (exception or compile error)? exception
which tutorial is important to look at? http://java.sun.com/docs/books/tutorial/essential/regex/quant.html
Which code snippets are important? 451 and 452
A method can never, ever, ever be marked as both abstract and final, or bothabstract and private.
The char type contains a single 16-bit Unicode character.
In a method with a primitive return type, you can return any value orvariable that can be implicitly converted to the declared return type? yes
What are assertions? Assertions let you test your assumptions during development, so you don't have to decalre exceptions when assuming something will never happen. Assertions allow you to test your assumptions during development, but the assertion code will evaporate when a program is deployed. An example of an assertions can be found in the middle of 384
Which table is important? table 7-6 on page 593
Can you delete a directory that's not empty? no
Do we invoke flush() when reading from a file or when writing to a file? or both writing
How do we do tokenization? String[] arrayOfStrings = argv[0].split([argv[1]); //for an example look at the code on page 503
Look at the exam watch on page ... 604
HashMap is ordered or unordered? sorted or unsorted? unordered and unsorted
Before generics, you had to cast the object returned by get. Now, it's done automatically. Look at the example on top of .. 598
If you're doing a lot of iterations, but not a lot of insertion and deletion, would you pick ArrayList or LinkedList? ArrayList
The synchronized keyword indicates that a method can be accessed by only onethread at a time.
You need to remember one key rule for interface constants. They must always bepublic static final
How do you get an instance of the pattern class? Pattern.compile("Meaw");
Look at the codes on pages ... 613 - 617
I have made a quick program to show the exception thrown for arrays. ReviewExample.java
What is [width]? it's the minimum number of characters to print
What does peek do? return the highest priority without removing from the Queue
Let's say you have an array of Cats, and you pass the array to a method that takes an array of Animals. The compiler will let you get away with adding a Dog in the method without complaining. However, it won't let u in generics. So if we pass <Dog> we mus NA
How do you print the integer portion of a string such as 1234.5434? nf.setParseIntegerOnly(true); nf.parse("1234.4343"); //this will print 1234. it should also be in a try/catch block
Which piece of code is important? Top of page 303
Is it appropriate to use assertions to validate arguments to methods marked public? private? No. Yes
FileReaders are at low level, which class wraps around them to improve performance and provide a more convenient way to work with data? BufferedReader (BufferedReader wrappes around FileReader)
What does charAt() do? Returns the character located at the index specified
If you define a new exception class that extends Exception, is it considered runtimeexception or not? Not. Hence, checked
If you have a Date object, how do you get the long number represeted by the date? d.getTime()
How do you decalrre an ArrayList polymorphically. (String ArrayList) List<String> array = new ArrayList<String>();
What are the two differences between HashTable and HashMap? HashTable is thread-safe. Also, HashTable doesn't allow any null keys or null values
If the booleans do exist, what does that tell us about the version of Java? that it's java 6
Where is an example of concat? Page 432 and middle of 433
If the pattern is aba and the source is abababa what are the indexes found? 0 and 4
What does the Scanner constructor take? The String we want to tokenize
What is another way of converting a primitive to a String in a difference radix? toXxxString(). Examples on page 242
How many Integer Wrapper classes are there? What are they? How many xxxValue() methods are there for each class? Six. Byte, Character, Integer, Double, Float and Short. Each has 6 xxxValue(). Therefore, there is a total of 36 xxxValue() methods
In generics, what do you call the thing that's between the angle brackets? parametized type or type parameter
Hasing retrieval is a two-step process. What are the two steps? Find the bucket using hashCode(). Then find the right element using the equals(). Exam watch on page 551
When creating files, what is important to always do? do try and catch (IOException e)
How do you enable assertions at runtime? java -ea TestClass or java -enableassertions TestClass. Assertions are disabled by default
Java supports only single inheritance this means a class can have only one immediate superclass
Why we didn't decalre a size for char[] on page 458? becaue we assign this reference variable to an array of the same type. doesn't matter whta size it is. We learned this before
What is a collection with natural order? It's a collection that has elements ordered in the natural order of the elements. And these collections are not only ordered, but sorted as well
So if you define a natural order for a class using Comparable, how do you define a different sort for the same class? using the Comparator class
What does delete do? what arguments does it take? delelte deletes a substring from a StringBuilder/StringBuffer object. it takes two arguments, start and end.
What is the result of having assert(x==1): ; compile error. The statement after the colon must resolve to a value
How do you convert an Array to a List? using the static method Arrays.asList()
What is the difference between "." and \w? "." includes spaces. /w doesn't include spaces
If you have List<Integer> meaw = new ArrayList<Integer>(); what do you call List? Integer? List and ArrayList are called base type. Integer is called generic type. Base types can be a class and a super class. Generics can't be. They should always be the same
So what does the syntax List<? super Dog> animals mean? it means accept anything that's a superclass of Dog or Dog itself. even Object is accepted
What arguments does a PrintWriter constructor take? File (as of java 5), String (as of java 5), Writer, OutputStream
Give a snippet of code to create a directory File dir = new File("myDir"); dir.mkdir();
String objects are immutable, so what is the result of you have too much string manipulation? too many abandon String objects in the String pool
'assert' can be used as an identifier in which Java version? 1.3. assert did not exist back then
How can you read an input from a user? readLine("%s", "Enter line of code") which is a method of Console
What is an error (The thing that's derived from Throwable) These are situations that happen not because of program fault, such as JVM running out of memory)
What is the optional argument that both parseXxx() and valueOf() take? radix, which is used to convert String objects from different bases
What are the possible constructor arguments for the following wrapper classes: Boolean, Byte, Character, Double, Float, Integer, Long and Short? boolean or String - byte or String - char - double or String - float double or String - int or String - long or String - short or String
What order will initialization blocks are run? In the order they are declared in the class (top to bottom)
How do you run some code just before an object is deleted? You put the code in finalize().
What are some of the meta-characters? \d for digits. \s for white spaces. \w for a word chracter such as a digit, a character or underscore (space is not included in \w)
So what happens if you serialize some object that has reference variables as instance variables and these references refer to classes that are not serializable (and you cannot make them implement Serializable because you don't have access to them) Use transient to prevent saving that instance variable. Look at the snippet on page 465
How many arguments does compare take? what type? two. of type Foo. Look at page 574
When you use Arrays.asList to convert an array to a list, what is true about the conversion? When you change the list, the change refelcts on the array as well. and vise versa. Look at the first code on page 579
What is a File object used for? It is NOT used for writing and reading from a file. It works on a high level such as creating files, searching for files, deleting files, making directories, etc...
What is the result if you catch a more specific exception after a general exception? compile error, because the second exception (specific one) would have been caught automatically in the general catch. Example on the bottom of 370
Will the code on page 618 compile? why or why not? no because we're adding something to the collection
So let's say you have a Date object, and you want to write it in a different format. How do you do it? Create a Date object. Create a DateFormat object using getDateInstance or getInstance. then with the newly created DateFormat object you call format(date). For an example look at the example on page 480
In the DateFormat class, when do you use getInstance and when do you use getDateInstance? you use getInstance if you are not supplying any arguments. The getDateInstance is used when you're supplying an argument (works without supplying arguments as well)
How about when we pass collections to methods that accept List<Animal> and we pass List<Dog>. Does that work? No. Look at the code at 611 and 612
How do you convert from a wrapper type object to a primitive? You use one of the many xxxValue() which takes no arguments
What kind of code can you have between the try and catch/finally block? None. You can't have any code in between
What does it mean for a collection to be ordered? It means you can iterate through the collection in a non-random order
How do you append a literal to the end of a string? concat. It's non-static that returns a reference. So does toUpperCase
If you have a Set or a List, how do you convert it to an Array? toArray() This method is not static. So you use the list instance to call it. Look at the example on page 579
Look at the code in the middle of page 620 and determines whether it'll work or not The answer is no because the <?> wildcard allows a list of ANY type to be passed to the method, but the add() method is not valid, for the reasons explained earlier (that you could put the wrong kind of thing into the collection). Therefore, the Bar class won't compile because it does an add() in a method that uses a wildcard (without super)
In a for loop, can you declare more than one variable in the first part of the for loop declaration? yes. as long as they are all the same type. Example on page 346
What is the result of x *= 2+5 if x is 2? 14. The expression on the right is always placed inside parentheses