Posts Tagged ‘scjp’

Sun Certification for Java2 Programming Part 2

Friday, December 19th, 2008
QUESTION
what is  default layout of dialog component
  

OPTION
a. FlowLayout
b. BorderLayout
c. GridLayout
d. CardLayout
e. GridBagLayout

ANSWER
b

www.pass4side.com
EXPLANATION
default layout for applet is FlowLayout
Frame has BorderLayout same as Dialog

——————————————————————————–

QUESTION
int j;
for (int i =3,j=1;j++,i–;j<3)
   if (j== i) contiune;
System.out.println(”i=”+i+” j=”+j)

what is the output of above code fragment.
  (more…)

Sun Certification for Java2 Programming Part 2

Friday, December 19th, 2008

QUESTION
what is the output of following code?
public class Test {

www.pass4side.com
        public static void main(String[] args){
          int i = 4, j = 7;
          String k = “string”;
          System.out.println(i+j+k+i+j);
        }
} OPTION
a. 47sting47
b. 11string11
c. 47string11
d. 11string47
e. Non of above is correct ANSWER
d QUESTION
What will happen if compile and run the following code?
public class Test {
public static void main(String[] args){
    StringBuffer k = new StringBuffer(”string”);
    StringBuffer s = new StringBuffer(”String”);
      if (s.equals(k))
         System.out.println(”Yes”);
       else
          System.out.println(”No”);
       }
}

(more…)

A Simple HelloWorld.java program for beginner

Friday, December 19th, 2008

HelloWorld.java Let’s look into our first program. Save the following text into the file called HelloWorld.java ——————————————————————————– class HelloWorld {
     public static void main(String[] args)
     {
           System.out.println(”Hello World!”);
     }
} ——————————————————————————– We examine that there is a class called HelloWorld. Since HelloWorld is the only class in the file, it is called the main class. The main class of the file has to be runnable in order to make your program runnable. In order to make your program runnable, you should have a function called main which is defined as:      public static void main(Strings[] args) The explanation is as follows: The public qualifier tells you that the function main is callable from outside. You don’t have to worry about this one yet as the concept of making a function private or public is later described in Object Oriented Programming (OOP) philosophy. Then the next qualifier is static. You don’t have to worry about this either.
Then, void tells you that the function main returns nothing to the system.
Then the function’s name, main.
Then String[] args denotes the argument passed into the program. The arguments are not used in the moment. What is an argument? It is the options or switches you would mention when invoking programs. Like in dir /w or ls -la both /w and -la serve as arguments. You can consider System.out.println as a command to print some text on the screen. Not that the text has to be surrounded by the double quotes. In this case, “Hello World!” is being printed, without the quotes of course. Remember that almost every command in Java ends with a semicolon(;). IMPORTANT: The main class name has to be the same as the program file name. Otherwise, your Java program won’t compile. In this example the class name is HelloWorld. The program file has to be HelloWorld.java. You have to pay attention that this naming convention is CASE SENSITIVE it means that naming your file into helloworld.java WON’T work. If your program won’t compile, pay attention to the capitalization of your file name. This rule also applies even in Windows platform. How to Compile and Run Your Program
In either Windows or UNIX, to compile the program, type the following command at your prompt: Don’t forget to change the directory to the directory where your Java program resides. Also, make sure that your JDK installation is correct. javac HelloWorld.java
In Macintosh, just drag your HelloWorld.java file into the Java Compiler icon. If it produces a file called HelloWorld.class, it means that your compilation is successful. To run it, under Windows or UNIX, type the following: java HelloWorld
Notice that there is no .class extension on it. Under Macintosh, simply double-click your HelloWorld.class file. Commenting Your Program
Sometimes, it is useful to make some note about your program. Not only making you clear about what’s going on your program, but also making others able to read your program based on the comments of your program. The compiler will completely ignore your comment, however. You cannot persuade the compiler to do your program eventhough your program has errors. In Java, there are three ways of commenting: Double slash comment. Example:
// Put your comments here
After you put the double slash (//), everything else behind it is considered as comment.
Embracing comment. Example:
/*
        My comment is here
        Neat huh?
*/
If your comment is pretty long, it is better to embrace it with /* and */. Everything within it is considered as a comment.
Java doc comment. It is similar to above, except:
/**
       My comments here will be put into
       documentation by Javadoc program
*/
It is embraced with /** and */. Notice the double star. Your comments within it will be documented by the Javadoc program, an automatic documentation maker from Java SDK package.  Well Done!
Well done! You have completed the first Java Program.

Sun Certified Java Programmer (SCJP)

Friday, December 19th, 2008

Sun Certified Java Programmer (SCJP) Overview

This foundation certification is for programmers interested in demonstrating proficiency in the fundamentals of the Java programming language. To achieve this certification, candidates must successfully complete one exam. It is not necessary to be a Sun Certified Java Associate prior to taking this exam.
Follow links for detailed information, exam objectives and to purchase:

- Sun Certified Programmer for the Java Platform, Standard Edition 6 (CX-310-065) - NEW!
- Upgrade Exam: Sun Certified Programmer for the Java Platform, Standard Edition 6 (CX-310-066) - NEW!
- Sun Certified Programmer for the Java Platform, Standard Edition 5.0 (CX-310-055)
- Upgrade Exam: Sun Certified Programmer for the Java Platform, Standard Edition 5.0 (CX-310-056)

Certification Preparation
Sun is pleased to take the guesswork out of preparing for certification. Learn about prerequisites, practice exams, coaching and recommended training options to help you achieve this certification. » More
Certification exams and training products must be purchased in the country where you reside. For inquiries outside this country, please select your local training office.

The information from : http://www.sun.com/training/certification/java/scjp.xml