B Barnett

Greenhorn
+ Follow
since Oct 03, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by B Barnett

Greetings:
If any one is currently using Visual Cafe Standard edition, please let me know how install the JSDK to work with it. I have searched the Sun site and the support pages for Visual Cafe and have found no help.
Your help is greatly appreciated,
B Barnett
SCJP
20 years ago
Greetings fellow JavaRanchers:
Yes, I have joined the ranks of the Sun Certified Java Programmers and am very happy. I shouted in the testing center when I got the results and danced all through the parking lot.
Okay, here is what everyone taking the test wants to know:
I do not have an IT background but wanted to change carrers so I attended a technical school for 10 months. We studied Java for a month and it just made sense to me so I decided that I would pursue that.
The books I used to prepare was Bill Brogden's Exam Cram 2 (thanx bill for a great job! i got my money's worth) & Java How To Program 3rd Edition by Harvey Deitel. I studied for about two months, approximately 5-6 hours a day after work.
The one thing you can't prepare for is the actual test experiencs. Taking the mock exams is less stressful because you know it doesn't count but when you are doing it for real and the money you paid is on the line it can be unsettling. So, first of all, I would say STAY CALM and don't second guess yourself.
Here we go with the format of the exam without giving away any actual questions:
- I got hit with 5-6 questions about java I/O off the top. You need to know what the legal constructors are for File Input Stream, Random Access File, etc. Also, you need to be aware that Input Stream and Output Stream are abstract class and what the implications are because of that.
- Be aware that a String object is always initialized to null. There were about 5 questions that were testing you on this. I was suprised that it came up so much.
- Be aware (don't assume) what the substring(0,3) method of the String class does. Don't assume, check the API.
- Know what the rules are for using the String.equals() method.
- Know pre-increment and post-increment inside and out. For example, x++, ++x, x--, --x.
- Know GridBag and Grid Layouts and what will happen to components when the window is resized.
- Did I mention, KNOW JAVA IO!!! thoroughly.
- Garbage Collection: You cannot force garbage collection. Get that straight before you take the exam. You can "suggest" the JVM do gc but you cannot force it. Also, know the implications to passing a variable to an Array then setting the variable to null. Is it eligible for gc?
- Speaking of arrays, know how to create 2-dimensional arrays and what happens if you try to to asssign a reference to a one-dimensional array to a 2-dimensional array.
- Know under what conditions you can assign a subclass reference to a superclass object and when you have to explicitly cast.
- You should have overriding/overloading rules down 100%. I ran into about 5-6 questions on that.
- Collections: know which allow for duplicate values and which do not. Know which ones will allow you to sort objects. Sutdy ArrayList, Vector, Map.
- Constructors. You need to know that if you define constructors that take arguments, the compliler will not create a default constructor. Also, know that a constructor for a subclass will call the default constructor for the superclass and what will happen if you did not create a default constructor for the superclass.
- Exceptions: Know when you have use try/catch and that the finally block is ALWAYS executed.
- Threads: these questions will kill you if you are weak on threads. I would urge you to practice live code using threads that attempt to modify private member variables. Know what the valid constructors are for a thread. Keep in mind, you can use this as an argument to Thread constructor. I had about 5 questions on this and these were the ones with the longest code lines.
- There were also some simple questions on language fundamentals. Yes, you need to know how to shift bits: >>, >>>, <<.
- There was one trick question I remember. Know that when you instantiate a superclass object and assign it a reference to a subclass, the compiler knows what type of object it really is. If you call a method, you are calling the method of what type of object is really is, not what you instantiated. I can not say anymore without giving away the question.
- Know what the valid access modifiers are for inner classes and how can they be created.

I took about 10 mock exams I must give Marcus Green the credit. His Mock exam #1 and #2 were the closest to the real thing except that some of his questions are much harder than what Sun gave me.
Thank you to everyone posting their questions. At least three of the questions on the exam had to do with questions people posted within the last week. I can not say which ones exactly without giving away the question. It is crucial that you post a question, no matter how silly you think it is because you might give someone a better perspective on something.
I will still visit this forum to help with questions where I can.
Thank you all
B Barnett




Greetings:
I am scheduled to take the exam on Sunday, October 15 at 1:00pm EST and wanted to clarify something. A lot of the people who have just taken the test have mentioned that there are several questions regarding overloading/overriding methods.
I have researched the JLS and the tutorial at Sun's website and also am using the Exam Cram book by Bill Brogden but I have not been able to locate a list of rules about overloading.
Can someone tell me, as concisely as possible, what conditions must exist for a method to be overloaded without causing a compiler error.
I understand that the argument list must be different. If the order of the arguments in the method is different, will it be considered overloading?
Example: public void method(String s, int i){}
public void method(int i, String s){}
//Is this considered overloading.
Please enlighten me as to what the rules are for overloading a method, whether in a class or subclass.
Thank you
- B Barnett

On Marcus Green's Mock Exam #3 Question 11 is as follows:

What will happen when you attempt to compile and run the following code
class Base{
public void Base(){
System.out.println("Base");
}
}
public class In extends Base{
public static void main(String argv[]){
In i=new In();
}
}
1) Compile time error Base is a keyword
2) Compilation and no output at runtime
3) Output of Base
4) Runtime error Base has no valid constructor
// End of Sample Code
I chose 3 because I was under the impression that even though the subclass "In" has no constructor the JVM would automatically make one.
My first question is will the JVM make a default contructor?
Second,
I was also under the impression that when an object of a derived class is instantiated, the superclass constructor is called first. In this case the constructor for class "Base" would be called thereby printing out the string Base.
Is this not correct also?
Thanks in advance,
B Barnett

I was doing Marcus Green's Mock Exam #3 and Question 6) is as follows:

Which of the following statements are true?
1) The instanceof operator can be used to determine if a reference is an instance of a class, but not an interface.
2) The instanceof operator can be used to determine if a reference is an instance of a particular primitive wrapper class
3) The instanceof operator will only determine if a reference is an instance of a class immediately above in the hierarchy but no further up the inheritance chain
4) The instanceof operator can be used to determine if one reference is of the same class as another reference thus
May answer was #1 and #2. The reason I chose #1 was because I was under the assumption that an interface could not be instantiated due to the abstract implementation. Therefore, there could not be a instance of the interface and subsequently there could not be a reference to a an interface. If there can not be a reference to an interface then option #1 makes sense: the instanceof operator can not be used to determine if a reference is an instance of a class.
What part am I not getting?
Thanks in advance,
B Barnett
Greetings group:
I just wanted to add my opinion. I feel like another way to design this would be to first have an abstract EMPLOYEE class with with a subclass of CHEF that has sublasses of HEAD CHEF and all the other types of chefs. Every chef is going to be an employee (theoretically) so why not make this the base class.
Just sharing my opinion
B Barnett
Greetings:
I was doing Marcus Green's Mock Exam # 2 and question #28 is as follows:
public class As{
int i = 10;
int j;
char z= 1; //**This line is what I have a question about**
boolean b;
public static void main(String argv[]){
As a = new As();
a.amethod();
}
public void amethod(){
System.out.println(j);
System.out.println(b);
}
}
I assumed there would be a compiler error becaucse I was under the impression that char primitives had to be initilized using single quotes ( '' ). Unfortunately, I have not been able to find much documention on this, only the Character class. Please let me know what are valid initializers for the char primitive.
Thank you
B Barnett
Upenda:
The equals method checks for object equality, not the value.
Because one reference is to an Integer object and the other one is to Long object, this will always return false.