Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By r035198x

Thread: 8 questions I dont understand while studying for SCJP

  1. #1
    shankhas is offline Member
    Join Date
    Jun 2008
    Posts
    2
    Rep Power
    0

    Default 8 questions I dont understand while studying for SCJP

    Hi all,
    I want to give my SCJP exam sometime this month. I was reading A Concise and Comprehensive Study Guide for SCJP by Dr. Paul S Sanghera. I would like to ask the learned members of this forum you a few queries that I have. I shall be grateful if you would kindly find time to reply me with your valuable suggestions

    1. I know that: If a class is declared final, it means the class cannot be extended, and a final method cannot be overridden. If the element declared final is a variable, that means the value of the variable is constant, and cannot be changed.

    My question is: If a final variable is inherited in another class, can it be accessed? And can its value be changed?

    2. My question is: Could you please give an example of method call conversion of object reference types?

    3. My question: Is it possible to inherit the main() method?

    4. My question is: What are anonymous inner classes? Where are they used practically? How are they defined? What is their scope? Can they access variables of the outer class? If so how?

    5. Can inner classes be defined inside a method? What is their scope? Can they access the variables within the method? Can they access the variables of the outer class?

    6. Are all methods defined in java.lang.Math static?

    7. What are factory methods?

    8. My question: Can interfaces have classes?


    Thanks for your help!
    waiting for your quick reply!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Most of this can be easily looked up. I counter your questions with a couple of my own: Have you looked these up and wouldn't it be wise for you to present your answers and justifications here first before asking for other's advice?

    This would serve two purposes. It would demonstrate that you've done your own work first, and will give a starting point for answers to your questions.

    Good luck.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes, most of the questions are not directly related with theories of Java. So you can simple write some code and see what happened. In that way you can learn a lot. First make a try.

  4. #4
    coyne20 is offline Member
    Join Date
    Feb 2009
    Posts
    20
    Rep Power
    0

    Default

    My response in red below:

    Quote Originally Posted by shankhas View Post
    Hi all,
    I want to give my SCJP exam sometime this month. I was reading A Concise and Comprehensive Study Guide for SCJP by Dr. Paul S Sanghera. I would like to ask the learned members of this forum you a few queries that I have. I shall be grateful if you would kindly find time to reply me with your valuable suggestions

    1. I know that: If a class is declared final, it means the class cannot be extended, and a final method cannot be overridden. If the element declared final is a variable, that means the value of the variable is constant, and cannot be changed.

    My question is: If a final variable is inherited in another class, can it be accessed? And can its value be changed?

    Yes it is accesible but you can not modify it whatsoever.

    2. My question is: Could you please give an example of method call conversion of object reference types?

    What exactly do you mean by this?

    3. My question: Is it possible to inherit the main() method?

    Yes you can but why would you want too?
    As main is defined as static. You can not override static.


    4. My question is: What are anonymous inner classes? Where are they used practically? How are they defined? What is their scope? Can they access variables of the outer class? If so how?

    5. Can inner classes be defined inside a method? What is their scope? Can they access the variables within the method? Can they access the variables of the outer class?


    public int someMethod()
    {
    class Test // class declaration
    {
    private int i = 5;
    public int getI()
    {
    return i;
    }
    }
    Test t = new Test(); // invoke an instance
    t.getI();
    }

    And yes they can access outer class members using the reference
    <OUTERCLASS>.this.<method/variable>;




    6. Are all methods defined in java.lang.Math static?

    Yes they are. Classic example is Math.PI.

    7. What are factory methods?
    Beats me what are they?

    8. My question: Can interfaces have classes?
    Hell no!

    Thanks for your help!
    waiting for your quick reply!

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by shankhas View Post
    2. My question is: Could you please give an example of method call conversion of object reference types?
    You mean that how to invoke (call) a method on a different class by using an object?

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by coyne20

    8. My question: Can interfaces have classes?
    Hell no!
    Java Code:
    interface Hell {
    	class No {
    		public static void main(String[] args) {
    			System.out.println("Hell, Yes!");
    		}
    	}
    }
    roshan092 likes this.

Similar Threads

  1. Hello! and I need help. I dont know were to start
    By Fall0ut in forum New To Java
    Replies: 10
    Last Post: 05-19-2010, 06:26 PM
  2. 400 Mock Exams Questions for SCJP 1.6
    By kks_krishna in forum Java Software
    Replies: 12
    Last Post: 11-19-2009, 04:34 PM
  3. SCJP 1.5 Certification Kit (300+ Questions)
    By kks_krishna in forum Reviews / Advertising
    Replies: 3
    Last Post: 12-16-2008, 05:43 PM
  4. 800 Mock Questions for SCJP 1.6
    By Enthuware in forum Java Software
    Replies: 2
    Last Post: 01-16-2008, 11:57 AM
  5. SCJP 1.6 Certification Kit (350+ Questions)
    By kks_krishna in forum Reviews / Advertising
    Replies: 0
    Last Post: 12-30-2007, 12:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •