Extending question

okay, so you have two classes, A, and B. Class B extends class A. When you create new B(), is A() called and a new instance created? and if you declare A null, does b go away too?

Jadz_Core wrote:
okay, so you have two classes, A, and B. Class B extends class A. When you create new B(), is A() called and a new instance created?Kind of.
What happens is this:
1. Space is laid out on the heap for the data that object B needs; this includes the fields (even the private fields) that came from class A
2. Class B's constructor is invoked, but the first line of the constructor must be a super constructor (a constructor in the base class). If the super constructor is not specified, the default (empty) constructor of the superclass will be called, thus
3. Class A's constructor is invoked, does what it has to do
4. stack returns to class B's constructor and proceeds with that.
and if you declare A null, does b go away too?The idea is that there isn't an A, there's a B that basically contains an A within it (B is a superset of A)

Similar Messages

  • Office Extend Question(s)

    I have a couple of questions surrounding the Office Extend 600 series access points.
    Currently we have 2- WLC5508s.
    1) In the Deployment guide it mentions turning off Aironet IE and Coverage Hole Detection. Is this required, or just highly recommended? What types of issues are we expected to encounter if we have Aironet IE and Coverage Hold Detection enabled with Office Extend AP's?
    2) In a Primary, Secondary configuration of WLC controllers, I would need to setup another NAT configuration for the second controller int he event of a failover correct? Any alternatives?

    Ok so I understand your oe will connect to inside controllers not a DMZ controller. Thats fine .. Here is another way to skin this cat ..
    You can create the same ssid as production but name it differently under the profile name. So you can have the same WLAN ssid name.
    Under the new WLAN number it above 16, same 100. Configure this one as spec'd in the oe manual.
    Then create an ap group for your oe aps and include WLAN 100 in the group.
    This way you can have the same ssid, different configs. Since the WLAN is above 16 they don't get broadcasted out unless you put the aps in the group.
    Make sense ?
    Sent from Cisco Technical Support iPhone App

  • Fabric Extender question to a dual-homed N5k

    According to latest release notes:
    http://www.cisco.com/en/US/customer/docs/switches/datacenter/nexus5000/sw/release/notes/Rel_4_2_1_N1_1/Nexus5000_Release_Notes_4_2_1_N1_1.html#wp144071
    "Support for a maximum of 12 Fabric Extenders dual-homed to a vPC Cisco Nexus 5000 Series switch pair and a maximum of 576 hosts connected to Fabric Extenders connected to Cisco Nexus 5000 Series switches"
    I have mixed mode so some of the FEX will only connect to one N5k despite the 2N5k will be vpc. Cisco calls this "Fabric extender straight-through topology". This is because I am running port-channel with VM on these particular FEX.
    http://www.cisco.com/en/US/prod/collateral/switches/ps9441/ps9670/C07-572829-00_Design_N5K_N2K_vPC_DG.pdf
    question is:
    1. Can I assume 2148 is included per release notes?
    2. Can I have more than 2 ports in the portchannels in straight-through mode?
    3. Release notes show 576 host which is (12 max times 48 ports). I assume I can have more logical host meaning vm host via the port channels, right...?
    Thx

    Any Nexus 5000 can have a total of 12 FEX's connected to it physically.  If you have 12 FEX's in dual-homed mode, then that is the limit for both Nexus 5000's.  If you had 24 FEX's evenly distributed between the Nexus 5000's in straight-through mode, then that would be maximum in that configuration.  If you are mixing straight-through and dual-homed configurations, you would have to be within the 12 FEX per Nexus 5000 limit.
    The 2148 is the first FEX, so yes it is the focus of the release notes.
    The 2148 cannot have a local port-channel.  This is why you can only channel to a 2148 when using dual-homed (called Active-Active mode), one interface on each 2148, and it is tied together with a vPC configuration to make a port-channel.  The individual 2148's each only have one connection on them down to the server below.  The 2248 and 2232 do not have this restriction.
    As of 4.2(1)N1(1), 576 refers to host interfaces.  If your host has virtual hosts, you just need to make sure you are within the limit of mac addresses in the system, which is 16,000 (13,800 unicast).
    Regards,
    John Gill
    Reference:
    configuration limits -
    http://www.cisco.com/en/US/docs/switches/datacenter/nexus5000/sw/configuration_limits/limits_421/config_limits_4_2_1_chapter1.html

  • Samsung Wireless Extender question

    I just received a Wireless Extender that I bought through Amazon's Marketplace.  The item was labeled as new and looked new when I opened it, but it was apparently refurbished or something, because when I called Verizon Customer Service to activate it, I was told that it is already active on somebody else's account.  The CSR said I should contact the seller to see whether they can deactivate it from the existing account or return it.  I assume that since this seller had several of these that it was some kind of liquidation sale or something, so my only option would be to return it and try again.
    Since the extender seems to be working and it's going to cost me a shipping charge each time I return one, and chances are the next one will have the same problem, I'm thinking about just keeping it and using it without the managment functionality.  I'm not paying Verizon $300 just to get one I know is new.
    So, my question is, is there any risk to using an extender tied to somebody else's account?  Can they see information regarding the devices connected to it, and if the registered owner happens to get their account canceled, will the device stop working?  
    Thanks,
    Martin 

    MartinMc wrote:
    So, my question is, is there any risk to using an extender tied to somebody else's account?  Yes.  The owner has the ability to manage the device and limit what phones numbers have "priority" connection to it, so you may find yourself unable to use the device if others are using it at the same time.
    Can they see information regarding the devices connected to it, No, I don't believe so.
    and if the registered owner happens to get their account canceled, will the device stop working?  Yes, if the device is not attached to active account, it will stop working.  I'm not positive, but I think the Extender would be treated the same way as a cell phone if the account is shut down due to non-payment, basically the Extender would be "locked" to that account and unusable until the account is paid up.
    Thanks,
    Martin 
    I'd reccomend getting an Extender that you can activate on your account.  That way you know it won't stop working unexpectedly.

  • Class extends question

    Hi Ive written a program in java3D and my class extends JFrame because i using swing for my GUI however i now want to use the mouse picking thing in java to click on shapes on my canvas which i see isnt 'too' hard but i cant now extend a second thing can i? is there a way around it? the code below is exactly what i want but it extends MouseAdapter which mine cant ?
    import com.sun.j3d.utils.picking.*;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Pick extends MouseAdapter
      private PickCanvas pickCanvas;
    public Pick()
        Frame frame = new Frame("Box and Sphere");
        GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
        Canvas3D canvas = new Canvas3D(config);
        canvas.setSize(400, 400);
        SimpleUniverse universe = new SimpleUniverse(canvas);
        BranchGroup group = new BranchGroup();
        // create a color cube
        Vector3f vector = new Vector3f(-0.3f, 0.0f, 0.0f);
        Transform3D transform = new Transform3D();
        transform.setTranslation(vector);
        TransformGroup transformGroup = new TransformGroup(transform);
        ColorCube cube = new ColorCube(0.3);
        transformGroup.addChild(cube);
        group.addChild(transformGroup);
        //create a sphere
        Vector3f vector2 = new Vector3f(+0.3f, 0.0f, 0.0f);
        Transform3D transform2 = new Transform3D();
        transform2.setTranslation(vector2);
        TransformGroup transformGroup2 = new TransformGroup(transform2);
        Appearance appearance = new Appearance();
        appearance.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_BACK,0.0f));
        Sphere sphere = new Sphere(0.3f,appearance);
        transformGroup2.addChild(sphere);
        group.addChild(transformGroup2);
        universe.getViewingPlatform().setNominalViewingTransform();
        universe.addBranchGraph(group);
        frame.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent winEvent) {
              System.exit(0);
        frame.add(canvas);
        pickCanvas = new PickCanvas(canvas, group);
        pickCanvas.setMode(PickCanvas.BOUNDS);
        canvas.addMouseListener(this);
        frame.pack();
        frame.show();
    public static void main( String[] args )
        new Pick();
    public void mouseClicked(MouseEvent e)
        pickCanvas.setShapeLocation(e);
        PickResult result = pickCanvas.pickClosest();
        if (result == null)
           System.out.println("Nothing picked");
        else
           Primitive p = (Primitive)result.getNode(PickResult.PRIMITIVE);
           Shape3D s = (Shape3D)result.getNode(PickResult.SHAPE3D);
           if (p != null)
              System.out.println(p.getClass().getName());
           else if (s != null)
                 System.out.println(s.getClass().getName());
           else
              System.out.println("null");
    }

    hi,
    first, you don't have to extend JFrame (even it seems convenient), try to honor the composition over the inheritance. second, if you listen to key or mouse events, usually it's enough and perfectly ok to implement proper listener interface and then implement its methods (fulfill the contract).
    what you did (extnding some mouse listener) i would assume that you're trying to implement a new mouse listener with specific behavior. but what you actually want is just to use it.
    this question is "on the edge" since it involves some general design decisions (so it could be in java programming section) and at the same time it touches the j3d apis (so it can be here).
    hope it helped;)

  • Photoshop CS5 extended question

    IS photoshop CS5 a program on its own... with 'extended' as a sort of.. add on to it?
    so i mean like.. if you don't have CS5 standard, and you buy CS5-extended, will you be able to use it, or will u have to buy the standard version with it?
    if not, then why is it that many sites are selling photoshop extended and such low prices.. around 1-400 pounds?

    The Extended version has more features.
    Please post follow ups in the Photoshop forum. This forum is for suite specific issues.
    Bob

  • EJB3 customizing/extending question

    I have an EJB module with some stateless session beans in it. They all are quite obviously currently deployed.
    I started down the road on the following thought experiment, which I'm fairly convinced is invalid, but thought I'd ask.
    Suppose I "buy" that fabled EJB jar that you're supposed to be able to purchase from so-called component vendors. And suppose I want, for whatever reason, to treat that ejb-jar file as much like a black box as possible.
    Now suppose that it ships with a WombatBean in it, whose ejb-name is WombatBean, and whose ejb-class is com.foo.WombatBeanImpl. Suppose I want to add an additional couple of attributes--semantically--to it, without cracking open the ejb-jar.
    Could I:
    * Write an EJB that extends WombatBeanImpl--suppose it's com.ljn.WombatBeanExtension--and pack it up in its own ejb-jar file
    * Somehow convince the EJB container to map the ejb-name of WombatBean to "point" at com.ljn.WombatBeanExtension, such that com.foo.WombatBeanImpl is always "shadowed"?
    I understand that I could sort of accomplish this and say that for all applications I know about I could go play games with ejb-refs and the like and point them all at my bean instead of theirs, but I guess I wanted to do this "underneath" the ejb-name they're all referencing.
    Does this make any sense? Am I waaaay off base here?
    Thanks,
    Laird
    P. S. If I can do this, but it's appserver-dependent, I'd appreciate those answers too. I'm using EJB3/JavaEE5 on Glassfish b32.

    ejb-name is only guaranteed to be unique within the scope of an ejb-jar, so by definition if the other
    ejb is in a different ejb-jar the ejb-names would not clash.
    Regarding the issue of sub-classing,
    it's not that you can't use implementation inheritance, where one of the super-classes happens
    to be the bean class of an EJB component. The point is that there is no special notion of
    component inheritance for beans. In other words, just because you write a class FooBean
    whose parent is a bean class with an @Stateless annotation doesn't make FooBean an EJB.
    FooBean would need its own component-defining annotation or an entry in an ejb-jar.xml that
    declares it as a bean. In addition, some of the ejb meta-data in the super-class would not
    apply to FooBean, such as its metadata for declaring which local/remote interfaces it exposes.
    There is a lot of complexity in defining rules for processing of the ejb annotations
    to support full component inheritance so the spec decided to limit this support to keep
    things simpler.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Lens (Extender) Question

    Would any benefit be gained by using a series III extender (x1.4 or x2.0) on a series I lens opposed to a series II extender - specifically an EF 500mm f/4 IS USM?

    Skirball wrote:
    That's not exactly correct.  In fact I believe Canon even advertised that you need the new "Series II" Super Telephotos in order to benefit from the increased AF speed.  When Canon released the Series III extenders they also updated the 300mm, 400mm, 500mm, and 600mm primes to a Mark II, specifically to work with the Series III extender and provide faster AF speeds.  I'm sure they did these 4 lenses since these are the ones usually used with extenders.  The new AF technology wasn't backwards compatible with older models (most of which where Mark I), but new models such as the 70-200 II would have the new electronics.  So in a sense there was a correlation between the Series III extender and Mark II telephotos.  I assumed this is what the OP was referring to.
    No, the Canon 70-200mm 2.8 IS II is not one of the new "Series II" Super Telephoto lenses so it not compatible with the new AF technology designed into the Series III teleconverters. 
    There is slightly better optics with the 1.4x III over the 1.4x II and most say noticeably better optics with the 2x III over the 2x II so it still may be worth paying extra for the Series III with your older EF 500mm f/4 IS USM.  
    Mike Sowsun
    S110, SL1, 5D Mk III

  • Acrobat 9 pro extended question about saving -- yes

    Hi guys,
    my problem is kinda simple: If i change a pdf document using acrobat 9 pro and save, it just saves at the original document I was opening. Of course, when I choose save to, it suggest the own documents folder.
    Problem now: If I change something and want to close it, the program asks me to save. If I answer yes, it doesnt just saves, it's suggesting the own documents folder, like I'd say "save to".
    Is there any possibilty to change this?

    I think the print margin aspect depends on how you are creating the PDF. If you open the graphics directly in Acrobat, the graphics will open with the margins defined in the graphic in the cases I have done. Small pictures have a real small margin and such. Laying what you want out in another application, be it WORD or one of the Adobe layout packages, is the better way to accomplish the task. Acrobat is meant to provide printing, not layout like you are trying to do.
    To put the graphics in directly and be able to adjust size, you would need to add blank pages and on each locate the image on a button (Tools menu). The button would then be set up with the ICON only, using the image at the icon. The advantage of this approach is that you can scale the graphic. If you import the graphic directly, you can not scale it.
    Again, the best approach is to use another program to layout your photos as desired and then print to the Adobe PDF printer. The other user has suggested WORD and that is one possibility. If you use WORD, be sure to use the ctrl-Enter or break menu to create new pages. Do not use line breaks to create the paging.

  • Help!! really easy screen extending question

    I am trying to link two monitors to the same computer I have the ATI Radion video card so I know I have all i need I just cant make this work. I am giving up on the idea and Figuring It would just be easyer if I got the adapter that would allow me to plug both monitors into one output and it would split the picture. (If that is possible). If so what should I be looking at?

    If you want a task bar in the second monitor there's a free utility called Multi monitor Task bar.
    It will give you a second taskbar just for applicatiions running in a second monitor.  It works in Vista and XP.
    As for playing a game on two monitors, there's a software solution for that.  I currently don't remember the name but there's software that will let you play games on more monitors than the game was coded for.
    For triplehead software solution there's SoftTH. If I remember the other software I'll post the name later.
    Hope this helps.
    Independent IT Support

  • Which is better for an outside studio? WDS or Extended?

    Hi guys, particularly Bob Timmons, have been looking at all your replies here...but I wonder, Tesserax on one forum here said if you were requiring to linearly extend a network using all n AXs TCs etc, a WDS is better than the "spoke" effect of an extended network in terms of coverage (without using powerline adaptors that is). I have a garden studio with my Mac Pro "seeing" a closely located AX that's got a green light, but it doesn't see the network at all...though by connecting an ethernet cable from this AX to my Mac Pro, I get an internet connection, so there must be some signal.... Inside I have a netgear wired router, bridge attached to a 1st Gen TC and another n AX. Would there be ANY advantage in changing the whole setup to a WDS network? Cheers. Chris M (London)

    The correct answer to an "extending" question will depend on your particular requirements, not necessarily the technology involved.
    Keep in mind that there are advantages (and disadvantages) to either method of extending using wireless only.
    It is true that some installations call for an arrangement of "main", "relay" and "remote" devices in a WDS arrangement. The advantage is that you get better wireless coverage over a "long" area. The disadvantage is that you will have a "g" wireless network (even if you have newer "n" routers) and you will lose 75% of the bandwidth capability of the network. I think you can readily see why you would not want to use the type of setup if it could be avoided.
    If a "main" and "remotes" in a hub and spoke arrangement will meet your requirements, that is by far the better method because "n" speeds are maintained on the network and the bandwidth is much better preserved.
    I would recommend the powerline adapter approach if the AirPort Express is not receiving an adequate signal or not extending it effectively. You'll have much better wireless performance with this type of setup and it will be much easier to configure than a WDS arrangement.
    Sometimes, wireless just won't work in difficult installations requiring long runs or multiple obstructions.

  • Questions about a MasterQuize program

    Hi, everyone.
    I got a in-class case study program like this in the class:
    * This class stores/represents a question that has one of two
    * answers: True or False.
    * <p></p>
    * It needs to track the following information:
    * <ul>
    * <li>Question text</li>
    * <li>Correct answer</li>
    * <li>The user's answer to the question</li>
    * <li>Points value</li>
    * <li>Category</li>
    * <li>Difficulty rating</li>
    * </ul>
    // Our question should allow us to do the following:
    // - Create question (constructor) -- may be overloaded
    // - Print (display) question
    // - Check client's answer for correctness
    // - Get points value for question (0 or max)
    //   - Add "No-BS" grading option
    // - Getting client's answer
    // - Check to see if answered by client
    public class TrueFalseQuestion
        // Class constants (to simplify changes to common values)
        public static final int MIN_DIFFICULTY_LEVEL = 1;
        public static final int MAX_DIFFICULTY_LEVEL = 5;
        public static final int DEFAULT_DIFFICULTY_LEVEL = 1;
        public static final int DEFAULT_POINT_VALUE = 1;
        public static final String DEFAULT_CATEGORY_VALUE = "none";
        // Class instance variables
        private String questionText;
        private String correctAnswer;
        private String userAnswer;
        private int pointsValue;
        private String category;
        private int difficultyLevel; // TODO: Set a range for difficulty levels
         * @param text The literal wording of this question
         * @param answer The correct answer for this question
         * @param pts The total points available for this question
         * @param ctgry Category keyword for this question
         * @param level The perceived/intended difficulty level of this question
         * <p></p>
         * Defines a TrueFalseQuestion object.
        public TrueFalseQuestion (String text, String answer, int pts, String ctgry, int level)
            // Set starting values for all instance variables
            questionText = text.trim();
            correctAnswer = answer.trim();
            userAnswer = null; // No user answer supplied yet
            if (pts >= 1) // We assume that every problem is worth at least 1 point
                pointsValue = pts;
            else
                pointsValue = DEFAULT_POINT_VALUE;
            category = ctgry.trim();
            if (level >= MIN_DIFFICULTY_LEVEL && level <= MAX_DIFFICULTY_LEVEL) // within range
                difficultyLevel = level;
            else
                difficultyLevel = DEFAULT_DIFFICULTY_LEVEL;
        // Simplified (overloaded) constructors
         * @param text The literal wording of this question
         * @param answer The correct answer for this question
         * @param pts The total points available for this question
         * <p></p>
         * Defines a TrueFalseQuestion with default values for category and difficulty level.
        public TrueFalseQuestion (String text, String answer, int pts)
            // Call pre-existing constructor with default category and difficulty
            this(text, answer, pts, DEFAULT_CATEGORY_VALUE, DEFAULT_DIFFICULTY_LEVEL);
         * @param text The literal wording of this question
         * @param answer The correct answer for this question
         * <p></p>
         * Defines a TrueFalseQuestion with the default point value, default category,
         * and default difficulty level.
        public TrueFalseQuestion (String text, String answer)
            // Call pre-existing constructor with default points, category and difficulty
            this(text, answer, DEFAULT_POINT_VALUE, DEFAULT_CATEGORY_VALUE,
                 DEFAULT_DIFFICULTY_LEVEL);
         * @param text The literal wording of this question
         * @param answer The correct answer for this question
         * @param pts The total points available for this question
         * @param ctgry Category keyword for this question
         * <p></p>
         * Defines a TrueFalseQuestion with the default difficulty level.
        public TrueFalseQuestion (String text, String answer, int pts, String ctgry)
            // Call pre-existing constructor with default points, category and difficulty
            this(text, answer, pts, ctgry,
                 DEFAULT_DIFFICULTY_LEVEL);
         * @param text The literal wording of this question
         * @param answer The correct answer for this question
         * @param ctgry Category keyword for this question
         * <p></p>
         * Defines a TrueFalseQuestion with the default point value and the default
         * difficulty level.
        public TrueFalseQuestion (String text, String answer, String ctgry)
            // Use default points and difficulty
            this(text, answer, DEFAULT_POINT_VALUE, ctgry, DEFAULT_DIFFICULTY_LEVEL);
         * @param text The literal wording of this question
         * @param answer The correct answer for this question
         * @param pts The total points available for this question
         * @param level The perceived/intended difficulty level of this question
         * <p></p>
         * Defines a TrueFalseQuestion with the default value for the question category.
        public TrueFalseQuestion (String text, String answer, int pts, int level)
            // Use default category
            this(text, answer, pts, DEFAULT_CATEGORY_VALUE, level);
        // Clients can invoke this method to retrieve the text of the current question.
        // We chose to return the text instead of printing it; this allows the client
        // to decide how it should be presented (via a GUI, over a network, etc.)
        public String getQuestion ()
            return questionText;
        // This method allows the client to store the user's answer inside the
        // TrueFalseQuestion object for easy comparison
        public void submitAnswer (String ans)
            userAnswer = ans;
        // This method reports whether the submitted answer matches the correct answer
        public boolean answerIsCorrect(String userAns) // This version does all the work
            if (userAns == null) // No response from user (yet)
                return false;
            else
                // Normalize and compare answers
                char key = normalize(correctAnswer); // Get 't' or 'f'
                char ans = normalize(userAns); // Get 't' or 'f'
                return (key == ans);
        public boolean answerIsCorrect ()
            return answerIsCorrect(userAnswer); // Call previously-defined version
        public int getPointsValue()
            return pointsValue;
        // Return the points awarded for the user's answer. This method does
        // NOT support partial credit; answers are either correct or incorrect.
        // If the "No-BS" option is selected, blank (unanswered) questions receive
        // 1 point automatically; otherwise, the score will be either 0 or the
        // question's normal points value.
        public int getPointsEarned(boolean useNoBSRule)
    System.out.println("useNoBS: " + useNoBSRule + "\tuserAnswer: " + userAnswer + "\tcorrectAnswer: " + correctAnswer);
            if (useNoBSRule && (userAnswer == null))
                return 1;
            else if (userAnswer == null)
                return 0; // Without "No-BS", treat blank problems as incorrect
            if (answerIsCorrect() == false)
                return 0;
            else
                return pointsValue;
        // This method returns true if the user has submitted an answer
        // for this question (regardless of whether that answer is correct)
        public boolean hasBeenAnswered ()
            return (userAnswer != null);
        // Private helper method to convert all answers to single lowercase
        // letters (in this case, 't' for TRUE and 'f' for FALSE)
        private char normalize (String input)
             if (input != null)
                  input = input.trim(); // Remove leading whitespace
                  input = input.toLowerCase();
                  return input.charAt(0);
             else
                  return ' ';
    import java.util.*;
    * This class represents a complete test or quiz.
    * Data stored:
    * - List of questions
    * - Total score earned
    * - Total score possible
    * - Name/title of test
    * - Instructions
    *  - Category/class assignment
    *  - Student (test-taker) name
    *  - Date test is/was taken
    *  - Time started
    *  - Time completed
    *  - Maximum time allotted
    *  - (List of) Maximum attempts per question
    *  - List of attempts per question
    *  - List of difficulty ratings per question
    *  - Assignment weight
    * Methods:
    * - Constructor
    * - Add question
    * - Display question
    * - Display test
    * - Display instructions
    *      - Generate random exam
    * - Take/administer test
    * - Get score
    * STUFF TO DO:
    * - Add time/date restrictions
    * - Add network access restrictions
    * - Add other restrictions/allowances?
    * @author (your name)
    * @version (a version number or a date)
    public class Test
        // Class constant
        public static final int MAX_NUMBER_OF_QUESTIONS = 10;
        // Class instance variables
        private String testName;
        private int scoreEarned; // What the student earned on the exam
        private int scorePossible; // Total point values of all questions
        private String instructions; // Exam header text
        private ArrayList<TrueFalseQuestion> questions; // Create inside constructor
        // Methods
        public Test (String name, String instr)
            testName = name;
            scoreEarned = 0;
            scorePossible = 0;
            instructions = instr;
            questions = new ArrayList<TrueFalseQuestion>(); //[MAX_NUMBER_OF_QUESTIONS];
        public String getInstructions()
            return instructions;
        public int getScore()
            return scoreEarned;
        public void addQuestion (TrueFalseQuestion q)
            scorePossible += q.getPointsValue();
            questions.add(q); // Automatically append question to end of test
        public String displayQuestion (int position)
            if (position < questions.size())
                return (position+1) + ". " + questions.get(position).getQuestion();
            else
                return null;
        public String displayTest ()
            String result = "";
            for (int i = 0; i < questions.size(); i++)
                result += (i+1) + ". (";
                TrueFalseQuestion t = questions.get(i);
                result += t.getPointsValue();
                result += " points)\n\n" + displayQuestion(i);
                result += "\n\n";
            return result;
        // Get test length (number of questions)
        public int length ()
             return questions.size();
        // Submit answer to a specific question
        public boolean answer(int number, String a)
             // Question numbers run from 0-(max-1) -- THIS WAS AN OFF-BY-ONE ERROR AT FIRST
             if (number >= 0 && number < questions.size())
                  TrueFalseQuestion t = questions.get(number);
                  t.submitAnswer(a);
                  return true; // Question was answered
             else
                  return false; // Unable to answer (nonexistent) question
        // Score exam
        public void scoreExam (boolean useNoBS)
             scoreEarned = 0;
             for (int i = 0; i < questions.size(); i++) // For each question in exam
                  TrueFalseQuestion t = questions.get(i); // get current question
                  scoreEarned += t.getPointsEarned(useNoBS);
    }// Test harness for the Test and *Question classes
    import java.util.*;
    public class QuizDriver
         public static void main(String[] args)
              // Create a new Test object
              Test exam = new Test("Sample Exam", "Select the correct answer for each question");
              setUp(exam);
              Scanner sc = new Scanner(System.in);
              System.out.println(exam.getInstructions());
              // Administer exam
              for (int i = 0; i < exam.length(); i++)
                   // Print out current question
                   System.out.println(exam.displayQuestion(i));
                   // Get user answer
                   System.out.print("Your answer: ");
                   String ans = sc.nextLine();
                   if (ans.equals("")) // Handle blank responses for unanswered questions
                        ans = null;
                   exam.answer(i, ans);
              // Get exam results
              exam.scoreExam(true);
              System.out.println("Your final score was " + exam.getScore() + " points.");
         private static void setUp (Test t)
              TrueFalseQuestion x = new TrueFalseQuestion("The sky is blue.", "true", 2);
              t.addQuestion(x);
              x = new TrueFalseQuestion("The first FORTRAN compiler debuted in 1957", "true", 5);
              t.addQuestion(x);
              x = new TrueFalseQuestion("Spock was a Vulcan", "false", 3);
              t.addQuestion(x);
    }This program is far from finishing.
    I have many questions about this program, but let me ask this one first:
    In the TrueFalseQeustion class, why are there so many constructors? What is the purpose of setting some of the variables to default values?
    Thank you very much!!!
    Edited by: Terry001 on Apr 16, 2008 10:02 AM

    newark wrote:
    Stop ignoring the error messages. You seem to think that an error message means you're doing the assignment wrong. It's probably a simple fix. Post the exact error messages, as well as the code that corresponds to them. The error message will tell you exactly what line the problem occurs on, so you know right where to look.Hi,
    After some modifications, the program now gives me the result the assignment wants when I run it. But I still have trouble with the MultipleChoiceQuestion class
    Here is the complete program
    QuizDriver class
    // Test harness for the Test and *Question classes
    import java.util.*;
    public class QuizDriver
         public static void main(String[] args)
              // Create a new Test object
              Test exam = new Test("Sample Exam", "Select the correct answer for each question");
              setUp(exam);
              Scanner sc = new Scanner(System.in);
              System.out.println(exam.getInstructions());
              // Administer exam
              for (int i = 0; i < exam.length(); i++)
                   // Print out current question
                   System.out.println(exam.displayQuestion(i));
                   // Get user answer
                   System.out.print("Your answer: ");
                   String ans = sc.nextLine();
                   if (ans.equals("")) // Handle blank responses for unanswered questions
                        ans = null;
                   exam.answer(i, ans);
              // Get exam results
              exam.scoreExam(true);
              System.out.println("Your final score was " + exam.getScore() + " points.");
         private static void setUp (Test t)
                                   Question x;
              x = new TrueFalseQuestion("The sky is blue.", "true", 2);
              t.addQuestion(x);
              x = new TrueFalseQuestion("The first FORTRAN compiler debuted in 1957", "true", 5);
              t.addQuestion(x);
              x = new TrueFalseQuestion("Spock was a Vulcan", "false", 3);
              t.addQuestion(x);
              x = new MultipleChoiceQuestion("What is the color of the car\na.Red\nb.Green", "a. Red", 3);
              t.addQuestion(x);
              x = new MultipleChoiceQuestion("What is the name of this class\na.CSE110\nb.CSE114", "b, CSE114", 3);
              t.addQuestion(x);
    }Test
    public class Test
        // Class constant
        public static final int MAX_NUMBER_OF_QUESTIONS = 10;
        // Class instance variables
        private String testName;
        private int scoreEarned; // What the student earned on the exam
        private int scorePossible; // Total point values of all questions
        private String instructions; // Exam header text
        private ArrayList<Question> questions; // Create inside constructor
        // Methods
        public Test (String name, String instr)
            testName = name;
            scoreEarned = 0;
            scorePossible = 0;
            instructions = instr;
            questions = new ArrayList<Question>(); //[MAX_NUMBER_OF_QUESTIONS];
        public String getInstructions()
            return instructions;
        public int getScore()
            return scoreEarned;
        public void addQuestion (Question q)
            scorePossible += q.getPointsValue();
            questions.add(q); // Automatically append question to end of test
        public String displayQuestion (int position)
            if (position < questions.size())
                return (position+1) + ". " + questions.get(position).getQuestion();
            else
                return null;
        public String displayTest ()
            String result = "";
            for (int i = 0; i < questions.size(); i++)
                result += (i+1) + ". (";
                Question t = questions.get(i);
                result += t.getPointsValue();
                result += " points)\n\n" + displayQuestion(i);
                result += "\n\n";
            return result;
        // Get test length (number of questions)
        public int length ()
             return questions.size();
        // Submit answer to a specific question
        public boolean answer(int number, String a)
             // Question numbers run from 0-(max-1) -- THIS WAS AN OFF-BY-ONE ERROR AT FIRST
             if (number >= 0 && number < questions.size())
                  Question t = questions.get(number);
                  t.submitAnswer(a);
                  return true; // Question was answered
             else
                  return false; // Unable to answer (nonexistent) question
        // Score exam
        public void scoreExam (boolean useNoBS)
             scoreEarned = 0;
             for (int i = 0; i < questions.size(); i++) // For each question in exam
                  Question t = questions.get(i); // get current question
                  scoreEarned += t.getPointsEarned(useNoBS);
    }Question
    public class Question
    // Class constants
      public static final int MIN_DIFFICULTY_LEVEL = 1;
      public static final int MAX_DIFFICULTY_LEVEL = 5;
      public static final int DEFAULT_DIFFICULTY_LEVEL = 1;
      public static final int DEFAULT_POINT_VALUE = 1;
      public static final String DEFAULT_CATEGORY_VALUE = "none";
      // Class instance variables
      protected String questionText;
      protected String correctAnswer;
      protected String userAnswer;
      protected int pointsValue;
      protected String category;
      protected int difficultyLevel; //TODO: set a range for difficulty levels
      // Constructors
      public Question (String text, String answer, int pts, String ctgry, int level)
          questionText = text.trim();
          correctAnswer = answer.trim();
          userAnswer = null;
          if (pts >= 1)
              pointsValue = pts;
            else
                pointsValue = DEFAULT_POINT_VALUE;
            category = ctgry.trim();
            if (level >= MIN_DIFFICULTY_LEVEL && level <= MAX_DIFFICULTY_LEVEL)
                difficultyLevel = level;
            else
                difficultyLevel = DEFAULT_DIFFICULTY_LEVEL;
        // Overloaded (simplied) constructors
        public Question (String text, String answer, int pts)
            this(text, answer, pts, DEFAULT_CATEGORY_VALUE, DEFAULT_DIFFICULTY_LEVEL);
        public Question (String text, String answer, int pts, String ctgry)
            this(text, answer, pts, ctgry, DEFAULT_DIFFICULTY_LEVEL);
        public Question (String text, String answer, String ctgry)
            this(text, answer, DEFAULT_POINT_VALUE, ctgry, DEFAULT_DIFFICULTY_LEVEL);
        public Question (String text, String answer, int pts, int level)
            this(text, answer, pts, DEFAULT_CATEGORY_VALUE, level);
        // Methods
        public String getQuestion ()
            return questionText;
        // Use this method to store user answers
        public void submitAnswer (String ans)
            userAnswer = ans;
        public boolean answerIsCorrect (String userAns)
            if (userAns == null)
                return false;
            else
                // Normalize and compare answers
                char key = normalize (correctAnswer); //Get the first letter of an answer
                char ans = normalize (userAns); //Get the first letter of an answer
                return (key == ans);
        public boolean answerIsCorrect ()// Why do we need two answerisCorrect() methods?
            return answerIsCorrect (userAnswer);
        public int getPointsValue ()
            return pointsValue;
        public int getPointsEarned (boolean userNoBSRule)
            System.out.println ("useNoBS: " + userNoBSRule + "\tuseAnswer: " + userAnswer + "\tcorrectAnswer: " + correctAnswer);
            if (userNoBSRule && (userAnswer == null))
                return 1;
            else if (userAnswer == null)
                return 0;
            if (answerIsCorrect() == false)
                return 0;
            else
                return pointsValue;
        public String getCorrectAnswer ()
            return correctAnswer;
        public boolean hasBeenAnswered ()
            return (userAnswer != null);
        private char normalize (String input)
            if (input != null)
                input = input.trim();
                input = input.toLowerCase();
                return input.charAt(0);
            else
                return ' ';
           TrueFalseQuestion
    public class TrueFalseQuestion extends Question
      public TrueFalseQuestion (String text, String answer, int pts, String ctgry, int level)
          super(text, answer, pts, ctgry, level);
        public TrueFalseQuestion (String text, String answer, int pts)
            super(text, answer, pts, DEFAULT_CATEGORY_VALUE, DEFAULT_DIFFICULTY_LEVEL);
        public TrueFalseQuestion (String text, String answer, int pts, String ctgry)
            super(text, answer, pts, ctgry, DEFAULT_DIFFICULTY_LEVEL);
        public TrueFalseQuestion (String text, String answer, String ctgry)
            super(text, answer, DEFAULT_POINT_VALUE, ctgry, DEFAULT_DIFFICULTY_LEVEL);
        public TrueFalseQuestion (String text, String answer, int pts, int level)
            super(text, answer, pts, DEFAULT_CATEGORY_VALUE, level);
        // Methods
        public String[] getPossibleAnswerChoice ()
            String[] possibleAnswerChoice = {"true", "false"};
            return possibleAnswerChoice;
    } MultipleChoiceQuestion
    public class MultipleChoiceQuestion extends Question
       public MultipleChoiceQuestion (String text, String answer, int pts, String ctgry, int level)
           super(text, answer, pts, ctgry, level);
        public MultipleChoiceQuestion (String text, String answer, int pts)
            super(text, answer, pts, DEFAULT_CATEGORY_VALUE, DEFAULT_DIFFICULTY_LEVEL);
        public MultipleChoiceQuestion (String text, String answer, int pts, String ctgry)
            super(text, answer, pts, ctgry, DEFAULT_DIFFICULTY_LEVEL);
        public MultipleChoiceQuestion (String text, String answer, String ctgry)
            super(text, answer, DEFAULT_POINT_VALUE, ctgry, DEFAULT_DIFFICULTY_LEVEL);
        public MultipleChoiceQuestion (String text, String answer, int pts, int level)
            super(text, answer, pts, DEFAULT_CATEGORY_VALUE, level);
        // Methods
        String possibleAnswers;
        public String getPossibleAnswers ()
            return possibleAnswers;
        public void addAnswerChoice (String answerChoice)
            String ansChoice = answerChoice;
            questionText += "\nansChoice";
            possibleAnswers = answerChoice;
        public void printAnswerChoice ()
            System.out.println (questionText);
    } I don't understand why the assignment wants me to build a method in the MultpleChoiceQuestion class to store the potential answer choices, I can make the program display the potential answer choices by including them in the questionText as following in the QuizDriver class
    Question x;
    x = new MultipleChoiceQuestion("What is the color of the car\na.Red\nb.Green", "a. Red", 3);
    t.addQuestion(x); I don't know how to allow the client to construct the list of answer choices one at a time(add one potential answer choice by calling the addAsnwerChoices() method once)
    Here are a few original sentences of my assignment which describe what I should do with the MultipleChoiceQuestion class
    Using TrueFalseQuestion as a model, develop a new MultipleChoiceQuestion class that can be used to represent a problem where the user must select one of several answer choices (e.g., "Select answer (a), (b), (c), or (d)."). This new question type should have all of the same externally-visible functionality as TrueFalseQuestion, except that it must:
    maintain a list of potential answer choices
    provide a method that allows the client to construct the list of answer choices one at a time (i.e., the client should be able to call an addAnswerChoice() method to pass a new answer option to the MultipleChoiceQuestion.)
    display (as part of the question text) the list of answer choices with appropriate letters ("abcd" instead of "0123") I don't understand what these sentences mean.
    1. "Maintain a list of potential answer choices"-- this reminds me of the getPossibleAnswerChoice() method in the TrueFalseQuestion class
    public String[] getPossibleAnswerChoice ()
            String[] possibleAnswerChoice = {"true", "false"};
            return possibleAnswerChoice;
        }I wonder that if the potential answer choices I have to store in the MultipleChoiceQuestion class are only letters "a", "b", "c", "d", etc, or include the answer text coming after the letters(eg. a.Red, b.Green)
    2. "provide a method that allows the client to construct the list of answer choices one at a time". How do I achieve the functionality "one at a time"? Do I need to pass the input of the client (a potential answer choice) to the variable of the method which stores the list of potential answers?
    3. "display (as part of the question text) the list of answer choices with appropriate letters". My question here is that: When the client type in one possible answer, should I append it to the variable questionText? (So I use the questionText variable in the methods of the first and second steps)
    Thank you very much for your nice help!
    Edited by: Terry001 on Apr 21, 2008 8:01 AM

  • MRI: How to deal with the NEW .js  files being added to MassReplaceIt?

    This question concerns the application "MassReplaceIt."
    I have read the Help menu on it but am not clear on it and want to make sure that my guess is correct before I go and do anything.
    THE RUN-UP TO MY QUESTION IS:
    I have 23 songs on my website. Each time I have to Publish All to .Mac, the .js files for those pages need to be edited or else the songs won't play.
    In MRI > Find, I have my 8 pairs of Find/Replace.
    In Files, I have my 23 .js files listed
    I set up that combintion above as my DEFAULT QUERY. I named it "For song edits in .js files." As I add new songs, the list lengthens.
    MY QUESTION IS:
    The bottomest line question is: How do I handle new .js files to MRI and use MRI to edit them out the first time? Thus far I have been doing the first edit manually. Can I use the same default query every time I add a new song or must I make a new query to use with new songs, and then add the new song .js file later on to the default query?
    And below is the fully extended question which doesn't presume anything:
    When I add a new song and go through the motions thru MRI of Adding a new file and the selecting it in my iDisk, and then I click "Replace" (which then goes thru the files and finds/replaces to bring all files up to date) does MRI know to just edit out the new .js file which has not been edited yet? I can see that even if MRI goes thru all the songs to check them for current-ness, it could just leave the unaffected files alone and work only on the new file, but is that the way MRI wants me to do it? Or another way?
    If MRI wants me to do it another way, then I figure that MRI wants me to use a new query, and then the question is: How can I set up MRI so that in addition to that default query above, I have only the 8 Find/Replace items and NO long list of 24+ .js files? Then, when I add a new a .js file I would use that Query to edit it out just for that one time. Then I would transfer the .js file to the default File list.
    I have it in my head that I would use the DEFAULT query only for after I do Publish All to .Mac as opposed to, "Here is a list of 25 files, but edit out only the new one."
    Am I wrong? (I speak only of iWeb tasks, not of other programs like word processors.)
    WHEW!
    Lorna in Southern California

    Well, it can't "find" something that isn't there...
    so if it's already been changed, it can't be changed
    again Does this make sense?
    Be sure to re-save your query as you add new pages to
    the list.
    Yes, it makes sense and it was my first instinctive thought, but I have FeDigiWo: Fear of the Digital World. FeDigiWo is what made me catch myself in Instinct Mode and ask: But would the program want me to do it that way? Is the program finicky?
    So, bottomest line: When I put in a new song, I will go to MRI > Files > +
    and then navigate to the file, open it, wait for it to show up in the files field, and then click REPLACE. Yes? OK.
    Lorna in Southern California

  • Which tablet/s can run executables created in LabVIEW 8.5?

    Background: I have created a VI that acquires data over bluetooth from a specific DAQ device. The VI is created in Windows 7 and LV 8.5. The VI is tested to work on the development machine. I'd like end users to be able to install and run an executable version of this VI from a tablet that has bluetooth capability.
    Question:  Which tablets can run executables created in LabVIEW 8.5? I think tablets running Windows 8.1, such as Surface Pro and Dell Venue Pro, should be okay but need a confirmation before I purchase one. Also, how about tablets that run other operating systems, such as Windows RT or Android?
    Extended Question: What tablets in the market can run LabVIEW 8.5 VIs (or in other words allow LabVIEW 8.5 to be installed)?
    Gurdas Singh
    PhD. Candidate | Civil Engineering | NCSU.edu

    Well since LabVIEW 8.5 isn't officially supported on Windows 7, or 8 you may have issues.
    http://digital.ni.com/public.nsf/allkb/B972242574D4BB99862575A7007520CB
    Of course many on the forums have stated being able to run older versions of LabVIEW on new operating systems without issue but know that from NI's perspective you should not be running LabVIEW 8.5 on Windows 7.  Which means no modern tablet.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How to set #HOST# variable used in Chart template using Multiple Domains?

    I have a extended question to How can I set #HOST# variable referenced in the Chart template?
    In addition to the Proxy layer, we are looking to use multiple sub-domain names into the same Oracle APEX instance (through the one DAD) each mapped to a different application id. Therefore I don't think the solution in the link will work for me - as this embeds a single domain name in the DADS.CONF.
    Two questions:
    - Is it possible to set the "HTTP_HOST" in "dads.conf" using an existing HTTP Header value? - my proxy can pass on the original domain as "HTTP_X_FORWARDED_HOST". So if it was possible to use (say: using whatever form/syntax of parameterisation is available) ?
    >
    PlsqlCGIEnvironmentList HTTP_HOST=%{HTTP_X_FORWARDED_HOST}
    >
    If it can then that would work for me. It would be great if modl_plsql handled this out of the box as I understand the "X-FORWARDED" approach is pretty standard in the proxy world including passing on original IP addresses. Hitting an phpinfo() site shows headers
    >
    HTTP_X_FORWARDED_FOR     192.168.2.100
    HTTP_X_FORWARDED_HOST     dev.mycompany.com:443
    HTTP_X_FORWARDED_SERVER     mycompany.com
    >
    - Alternatively is it possible in APEX environment to set the #HOST# from the HTTP Header "HTTP_X_FORWARDED_HOST" if it exists for all requests?
    Thanks

    Hi Donna,
    changing the CGI environment variables HTTP_HOST, REQUEST_PROTOCOL and SERVER_PORT is the correct way how to resolve this, because it appears that your hiding the web server where you have installed mod_plsql or EPG by a different outside facing web server (also called reverse proxy). That's why APEX gets the host name, protocol and port of the internal web server, but should actually get the values of your reverse proxy web server. Can can fix that by changing the following CGI environment variables.
    HTTP_HOST should just contain the domain name (no protocol or port). For example: www.oracle.com
    REQUEST_PROTOCOL should contain http or https
    SERVER_PORT should be the port for https
    I don't want to add a new cgi variable called HOST because HOST sounds so generic and it might interfere with something else running in our environment. Or, I don't want to change the plsql cgi environment variable (such as HTTP_HOST) because many developers may use owa_util.get_cgi_env('HTTP_HOST') to get the current server. If the SERVER_PORT is part of the #HOST# then what could I change it to if it needs to be null. If you leave it blank, then the default SERVER_PORT comes from the CGI variables.The value of HTTP_HOST is wrong anyway and points to your internal web server, but I assume your developers actually want to get the host name of your external web server if they use it to generate absolute URLs. That's why I wouldn't bother and set it to the correct host name.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

Maybe you are looking for

  • Blue Screen Error while login screen in My Compaq CQ40 133TU

    Mate ,  I cant login my system. when i swtich on my sytem till login screen it ll coming , but after that showing blue screen error wth this error code  *** stop : 0x0000008E   (0xc0000005, 0x0044005C, 0x92000908, 0x00000000) What to do ? Please give

  • Windows xp printer sharing to Mac OS 10.6.7

    Hello everyone? Im mac newbie. My small office network have 2 computer. 1 computer is a windows XP and another one is macbook. My network solution is wireless. I'm installing and configure canon mf4680 printer on my windows xp computer. Then sharing

  • How to make use of BAPI_CATIMESHEETMGR_CHANGE

    Hi All,        We need to make use of BAPI_CATIMESHEETMGR_CHANGE for changing entered hours against an activity instead of adding new row for the same(BAPI_CATIMESHEETMGR_INSERT does that ) . Please guide me what all table parameters we should supply

  • Oracle InstantClient with Linked Server in Sql Server 2005

    We are trying to connect ORACLE server from sql server 2005 using Linked Server Feature in SqlServer 2005 Generally Oracle Client software is needed for this activity in the sql server machine. Can we use "Oracle InstantClient" instead of "Oracle Cli

  • Header row

    I am moving to a Mac from a PC using Excel. In my Excel spreadsheet the top row stays on top no matter how far I scroll down. (It's easy to set up.) I can't seem to be able to do it in Numbers. Can anyone help me with this? Thanks, Fred