John Mercier

java programming and scjp

  • Blog
  • Projects

A Standard Search Pattern for SCJP Questions

Posted on April 22, 2010 by John J Mercier

Filed under Programming | 0 Comments

Noodle Food is a blog that I have been reading on and off for a few years now and recently there has been a post that got me thinking of strategies for dealing with SCJP questions. The post by Paul Hsieh talks about developing a standard "search pattern" for studying x-rays and I think the idea of a standard "search pattern" for java questions should be developed. So I'm going to list some things to look for in SCJP questions. Note: This is for questions that have very general answers (Compiler error, checked exception, runtime exception). Obviously if it's a question that doesn't have these general answers you don't have to worry about it, but, from what I understand, SCJP has these answers on most questions. So, it's important to look for these things in your search pattern.

The Search Pattern

Sometimes you may look at a question and have a gut feeling that something is wrong. When this happens you should immediately look at the provided answers and see if it is in there. If it is make sure that it does not conflict with other answers and use that answer. This guide is not a complete strategy to taking the exam it is only for questions that are too complicated for the answer to just pop out. It is a systematic way of looking for problems in code.

First check the order as if it were in a java source file. First package, second imports, and then classes. Only one class can be public and of course the file must have that classes name. Next, check for correct blocks of code. All code must be in a set of curly brackets with semicolons after each statement.

Next, check for valid identifiers and assignments. Don't for get to check assignments in for loops. If polymorphism is used make sure the assignment is correct. If and assignment is made with a return from a method check the access to that method along with the return type. If the method throws an exception make sure that it is handled during the assignment. You do not have to go through the method line by line at this point.

The next thing to look at are conditional statements. if, for, while, assert all have conditions that may not make sense. Look for assignments (=) instead of equality checks (==). Look for method calls that do not return boolean.

Line by Line Search

The idea of a line by line search is to start from the beginning of a program and figure out exactly what each line does. If the question does not have a main method the question will usually tell you where to start. Once you find an error don't lose your place. It may not be the answer the question is looking for.

Well this is all I'm going to write on this for now. I'm sure as I go through the book I will find things to add.

Share |

SCJP Certification

Posted on April 21, 2010 by John J Mercier

Filed under Programming | 0 Comments

For a few weeks, while I've been finishing my calculus class, I've been looking at my java books wishing I had something to show for all that I have learned. I have 2 reference books, and two of the Head First books. I believe the best way to show knowledge of java is through the Sun Certification programs. I have been thinking about how much I want to get the SCJP Certification. There are two reasons I want to get the cert. First, it will be my only professional certification. Second, if I ever decide to get a different job it will be for programming.

Before I write what I'm doing to prepare for the cert I have to say that I have already studied for the exam less than a year ago and decided not to take it. I bought the study guide by Kathy Sierra and Bert Bates, wrote a ton of note cards, and even got passing scores on some of the practice quizzes. I was well on my way to getting the cert, but my life was getting to stressful and the goal of being certified seemed impossible. There are a few things causing this stress. I was getting out of the Navy and in the process of finding a job, taking two college classes, and worrying constantly about my future (This may have something to do with my recent return from Afghanistan). Now that I have a good job that I like, I feel less stress and I am ready to get the certification.

What am I doing to study? Yesterday I started my studying. I own a Sun Learning CD-ROM with 5 courses covering a lot of the java programming language. There are practice exercises and a lot of information that will help. The Getting Started section is done so far.

I'm also re-reading the SCJP book. I like to read things from start to finish but I've already been through this book a few times. I plan on going through it once, skimming through the sections I know and reading the ones I don't. After that I'm going to take as many practice tests as I can.

The test questions for this certification are complicated. They incorporate many concepts into one question that you almost have to be a human compiler to get them right. In fact a majority of the questions have "Does not compile" or something similar as an answer. It's really important to learn how to read a question (check for compile errors, runtime exceptions) and come up with the right answer. Practice makes perfect! And I know I need to take as many tests as I can.

Share |

HTC Eris command line access

Posted on March 25, 2010 by John J Mercier

Filed under General | 0 Comments

Recently, the screen to my LG Voyager started to go out and I had to buy a new phone. I decided to go with the Eris because it's cheap and It has android on it. I've never had a phone with the internet and I always thought it was a scam, but since I started this new job I've realize how much a good phone can keep my organized.

So, I got the Eris and messed with a few apps and found ConnectBot. It is used to connect to computers using ssh and telnet but there is also a local option. This option opens a command line for the phone itself. I'm not sure what this can do but it looks like the phone is not logged in as root so it probably doesn't do much. I just think it's cool to see what is under the hood of my phone.

Share |

Moving Text in SQL Server

Posted on March 19, 2010 by John J Mercier

Filed under General | 0 Comments

Hello everyone, I just wanted to post something cool I figured out at work.

Problem: You need to copy one field in a table to another field in the same table for all rows but that field has single quotes.

 field1  field2
 John's  
 it's  
 wasn't  

Solution: Well it looks like you will need to select everything in field one and create an update command to copy it to field two. To select everything in field one you can use

select field1 from tablename;

but this does not create the update statements needed. Try adding a string

select 'update tablename set field2=''' + field1 + '''' from tablename;

Now you will have to copy the output of this query into a new query and run it.

update tablename set field2='John's' from tablename;

You should get an error because of the single quote. It will tell the server that the string has ended and the rest is part of the query command. So, 'John' is the string and s' is just a syntax error. Single quotes can be "escaped" by using two single quotes instead of one. So, John's will become John''s. To do this within a query you can use the replace function in the first query.

select 'update tablename set field2=''' + replace(field1, '''', '''''') from tablename;

The result will be

update tablename set field2='John''s' from tablename;

The real benifit of using this method is when there are large text fields that need to be copied. It can also be useful when there are hundreds of records to be moved. The only problem I see with this method is the large amount of text it can generate for each update command. It may be possible to use the in statement to select the text from the database rather than putting it all into the query.

Share |

Setting up nvidia drivers on ubuntu 9.10

Posted on January 23, 2010 by John J Mercier

Filed under General | 0 Comments

I recently wiped my dell xps m1210 and reinstalled ubuntu. It has been over a year since I have had to worry about the nvidia support on linux I wanted to make a post about it so I can remember everything I have to do to get this thing working right.

For those of you new to this, linux does not like proprietary software. I'm not sure how this makes linux better than windows but it really makes it hard for new users to get the best out of their system. Some of the major issues that come with linux are easily fixed in windows. Those issues are dvd support, multimedia files (such as mp3, mp4, and avi), sound drivers, video drivers. Today I'm going to work on video drivers.

Ubuntu makes installing video drivers pretty easy. All I had to do to install it was click system->administration->Hardware Drivers. The program will look for a nvidia driver to activate and make it work. Now, this is much better than when I first started using linux. I used to have to download the source for the drivers, compile them, and install them.

There are many problems I have with the nvidia driver. For one thing I use a laptop. I need to be able to quickly hook up a second monitor and use it with my laptop closed. On ubuntu this is not a fast process at all. I need to switch to that monitor using Fn+F8 twice. Then, when I close the laptop it goes into sleep mode. So, I have to make sure that is turned off in power management. Now that I am on my other monitor I have to adjust the screen resolution. My laptop has a 1280X800 resolution and my monitor is a 1920X1200. I'm not going into any more details on how difficult it is to get everything properly setup. It takes way to long and it is one of those things that keeps users away from linux.

Share |

Google Chrome

Posted on January 23, 2010 by John J Mercier

Filed under General | 0 Comments

I remember the first time I heard of google chrome I had just completed changing my OS from Windows XP to fedora linux. The change was complete and I had not yet tried running windows on a VM. I didn't try to install chrome until I switched from fedora to Ubuntu, when I found out that chrome does not hava a linux installer. It sucked that I could not use if at all but I decoded to try it on a windows vm. Well, now my browser experience is about to completely change because google has finally came out with a linux installer.

Google chrome beta is not in the ubuntu repository, and although I hate manually installing software I had to try this out. The browser is easy enough to install. Just go the the site, download the package, and use any package manager to install it. It's so nice that linux can easily install software. This is one of the reasons I decided to switch. I remember having to always compile software to get it working, and linux books always start out with compiling software from source to install it. For a new user this can be annoying. I don't think linux better at installing software than windows, its just that linux has improved so much that I love the way it works now.

There are a few issues that I have with chrome so far. First, it doesn't use the ubuntu theme at all. If there is a way to make it look like all the other windows I haven't found it yet. Second, the dialog boxes do not fit into my netbook's  small screen. This is a big deal to me since I use my netbook more than any other computer I have. Google should incorporate scroll bars into all dialog boxes so users can view content that may go off screen. Netbeans does this and it works great on my netbook.

One thing that I like about Chrome, besides its speed and awesome layout, is the extensions. The only extention I use is xmarks so this makes chrome more usable for me. So, the only thing that chrome needs to do is fix the dialog boxes and I will be sold on it. Google, thanks for this wonderful product. The wait was worth it.

Share |

Album Creator 1.0a

Posted on December 19, 2009 by John J Mercier

Filed under Projects | 0 Comments

Image ConverterAlbum Creator 1.0a
Released: February 21, 2009
Created: April 2, 2007

Album Creator 1.0a is a program I wrote to generate the photo album for VAQ-138. It was really only used once, but I learned alot about swing, multi-threading, velocity, Netbeans, and Java2D. Please, read the webpage to learn more about why and how this program was made.

Share |

Added bookmarks using roller

Posted on December 19, 2009 by John J Mercier

Filed under johnmercier.com | 0 Comments

Now all of my links to external sites are generated using the bookmarks stored in roller!

Share |

wired networking fixed on 1005HA

Posted on December 17, 2009 by John J Mercier

Filed under General | 0 Comments

Today, I figure out how to install my wired lan driver on linux. It is pretty simple, but I had a hard time getting the AR81Family-linux-v1.0.0.10.tar.gz file. I emailed the atheros website to see if they could fix their broken links. Updates on that later. Here are the simple steps to get it working.

1. download the AR81 driver (I could only find the 1.0.0.9 version because the atheros website is broken).
2. switch to the src directory and run make
3. run make install

After this I had to restart and it worked.

Share |

Working theme

Posted on December 09, 2009 by John J Mercier

Filed under johnmercier.com | 0 Comments

Hello everyone! Right now you may notice that everything looks like crap. Well you are going be dealing with this for a while and (depending on your opinion of my design skills) possible forever. That is right folks I'm working on my own theme.

So far, I only have the basic files set up in roller so that I can edit the theme at my own pace. I hope to have the theme work for the entire website (except old pages) using templates for the index and project pages.

As a side note I think I found a bug in roller. The roller-startup.log file cannot be set in the roller-custom.properties file. Let me explain. For some reason I was getting a long error in the Catalina output saying that the log file could not be created. This is probably because of my shared server environment being locked down and not allowing this file to be written wherever it goes by default. Anyways, I tried to change the property in the roller-custom.properties file (because that is where all changes should be, right?) and I still got the error. I believe that this property cannot be set in this file because the file is loaded after the log is used. So, I had to change the path in the file I'm not supposed to edit log4j.properties. Not a big deal, but the file says I should be making this change in roller-custom.properties.

Well that is it for my rant. I will continue working on the theme so things can look nicer.

Share |

« Previous page | Main | Next page »

Search

Tag Cloud

activism addthis.com data_structure downloading facebook google google-buzz introduction java javablackbelt jdbc johnmercier.com jsp linux model-1 netbeans nvidia objectivism official-english programming projects pti roller scjp server sql theme uncertainty velocity welfare-state

Friends

  • Ed
  • Shane

Links

  • Glazed Lists
  • JGoodies
  • Java Specialists
  • Swing 2.0
  • Swing Generics
  • ideone
  • pircbot

Feeds

  • All
  • /General
  • /Projects
  • /Programming
  • Comments

Referrers

  • direct (46)
  • www.semrush.com/info (1)

Navigation

  • John Mercier
  • Weblog
  • Login

©2010 John J Mercier.

Designed by Free CSS Templates. Template by E. Strokin. Powered by Roller Weblogger 4.0.1.