Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Do You Know the Answer to Java Quiz?

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Do You Know the Answer to Java Quiz?

    Q1.
    public class InitTest {
    public static int VALUE = 100;

    static
    {
    System.out.println("VALUE1 = " + VALUE);
    VALUE += 200;
    System.out.println("VALUE2 = " + VALUE);
    }

    public InitTest() {
    System.out.println("VALUE3 = " + VALUE);
    VALUE += 300;
    System.out.println("VALUE4 = " + VALUE);
    }

    public static void main(String args[]) {
    new InitTest();
    new InitTest();
    }
    }
    Output:


    Q2.
    public class InitTest {
    public static int VALUE = 100;

    static
    {
    System.out.println("VALUE1 = " + VALUE);
    VALUE += 200;
    System.out.println("VALUE2 = " + VALUE);
    }

    public InitTest() {
    System.out.println("VALUE3 = " + VALUE);
    VALUE += 300;
    System.out.println("VALUE4 = " + VALUE);
    }

    public static void main(String args[]) {
    new InitTest();
    new InitTest();
    }
    }

    Output:


    Q3.
    String a = "abc";
    String b = new String("abc");
    String c = "abc";
    System.out.println(a==b);
    System.out.println(a==c);
    System.out.println(a.equals(b));

    Output:


    Q4.
    String a=null;
    if (a!=null && a.length()>10) {
    System.out.println("pass");
    }

    Output:



    Q5.
    String a=null;
    if (a!=null & a.length()>10) {
    System.out.println("pass");
    }

    Output:



    Q6.
    int i = -1;
    System.out.println(i>>31);
    i = -1;
    System.out.println(i>>>31);

    output:



    Q7.
    try {
    System.out.println("Pass 1");
    System.exit(0);
    System.out.println("Pass 2");
    }finally {
    System.out.println("Pass 3");
    }

    Output:



    Q8.
    try {
    System.out.println("Pass 1");
    return;
    System.out.println("Pass 2");
    }finally {
    System.out.println("Pass 3");
    }

    Output:



    Q9.
    byte a = 100;
    a = a + 20;
    System.out.println(a);

    Output:



    Q10.
    try {
    RandomAccessFile raf = new RandomAccessFile("c:\\file.txt", "r");
    System.out.println("Open");
    raf.read();
    System.out.println("Read");
    } catch (IOException ex) {
    ex.printStackTrace();
    } catch (FileNotFoundException ex) {
    ex.printStackTrace();
    } catch (Exception ex) {
    ex.printStackTrace();
    } finally {
    System.out.println("Finally");
    }

    Output:













    Answer: http://dbblogger.blog.com/2012/07/13/java-quiz/
    Last edited by dblog616; July 13th, 2012 at 04:40 PM.


  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    83
    My Mood
    Cynical
    Thanks
    3
    Thanked 9 Times in 9 Posts

    Default Re: Do You Know the Answer to Java Quiz?

    This looks to be a spam/non-question post in a question part of the forum, and also suspiciously like the posting of copyrighted material without permission. I'm not sure what the rules are for this forum, but I am notifying the moderators so that they can decide.

Similar Threads

  1. how to make a java code of a shaded answer sheet..?
    By wap in forum Java Theory & Questions
    Replies: 4
    Last Post: June 28th, 2012, 07:21 AM
  2. Making a Java quiz with Classes
    By diagnonsense in forum Java Theory & Questions
    Replies: 2
    Last Post: March 26th, 2012, 07:53 AM
  3. [SOLVED] Taking a square root in Java, answer appears as 0.0. Why?
    By r19ecua in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 30th, 2012, 11:47 AM
  4. Free Java quiz .
    By skoiloth in forum Totally Off Topic
    Replies: 11
    Last Post: January 9th, 2012, 11:16 AM
  5. [SOLVED] Addition Quiz
    By javaneedhelp in forum Loops & Control Statements
    Replies: 5
    Last Post: October 9th, 2011, 01:55 AM