How come this program compiles?

class Base
     Base()
          int i = 100;
          System.out.println(i);
public class Pri extends Base
     static int i = 200;
     public static void main(String[] args)
          System.out.println(i);
          Pri p = new Pri();
i get very confused here. in the main, the value of "i" will be printed to the standard output even before the class Pri is instantiated! how come this program can compile?
your help will be very much appreciated.
eileen2

This is because your class Pri extends Base. Because you didn't specify any class Pri constructor, java automatilcally created a no-argument constructor of class Pri with a call to the superclass constructor Base(). You can validate this by adding another Base constructor with arguments and then removing the no-argument Base constructor. Pri() will not compile.

Similar Messages

  • When recording a video using quicktime and my built in camera (isight) how come the program wont let me use my audio interface rather than the built in mike?

    when recording a video using quicktime and my built in camera (isight) how come the program wont let me use my audio interface rather than the built in mike?

    when recording a video using quicktime and my built in camera (isight) how come the program wont let me use my audio interface rather than the built in mike?
    The basic answer is that Apple has not programmed the capture routine with this capability. As such, you can always send QT feedback requesting this feature be added as a future enhancement.

  • How was this program done?

    Any ideas as to how this program was created?
    It allows you to view a short 3d animation of each tecnique,
    which you can also rotate left or right a full 360, or view from on
    top...you can control playback speed and make either the attacker
    or defender dissapear...
    I am curious how the 3d space was created and then inserted
    into an executable program...
    http://www.aikido3d.com/

    BKearney1 wrote:
    > I purchased the program to play around with and check it
    out...and there seems
    > to be more to it than what you describe as to how it was
    made...it appears to
    > be an animated 3d clip, which I agree was done in some
    3d application...but the
    > part that has me confused is how did they then build in
    the ability to spin 360
    > degrees around the animation while it was playing...you
    can actual spin around
    > the characters....I can spin the point of view of the
    camera a full 360 around
    > the two characters while the animation is playing, or
    pop to a top view...or
    > even a follow option...it seems that if this was a
    series of images you would
    > not be able to do some of these things...or it would
    take a tremendous number
    > of images?
    I did not see the program, I have only seen the stuff
    available on websites and that's
    how we do it in Flash. Frame by frame, than action script to
    control the frames.
    Based on mouse move (distance in pixels) or coordinates of
    the mouse versus the
    clip size the movie jumps to corresponding frame. Most of the
    360 done in such way.
    The application could be done in Director. You said CXT and
    these in fact are Director
    Protected Cast Files. Director has 3d capabilities and is way
    more powerful than flash
    when comes to desktop delivery.
    Best Regards
    Urami
    !!!!!!! Merry Christmas !!!!!!!
    Happy New Year
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Why doesn't this program compile?

    Compiling this program:
      public class Foo<T> {
        private final Class<T> type;
        public Foo(Class<T> type) {
            this.type = type;
        public T cast(Object obj) {
            return this.type.cast(obj);
        public void handle(T obj) {
        static void apply(Foo<?> foo, Object obj) {
            foo.handle(foo.cast(obj));
      }gives this error:
        Foo.java:12: handle(capture#31 of ?) in Foo<capture#31 of ?>
          cannot be applied to (java.lang.Object)
        foo.handle(foo.cast(obj));
        ^But this seems bogus. Obviously the result of foo.cast(obj) (generic type T) should be compatible with handle(), which takes a T.
    Am I missing something or is this a compiler bug (or limitation)?
    This is on openSuSE 11.1:
        $ javac -version
        javac 1.6.0_0
        $ rpm -qf /usr/lib/jvm/java-1.6.0-openjdk/bin/javac
        java-1_6_0-openjdk-devel-1.6_b16-0.1.3Thanks for any insights.

    endasil wrote:
    alc wrote:
    Thank you, this I understand... though it's a little disappointing the compiler can't make the simple inference required. I guess that would require data flow analysis.Which is easier said than done, and sometimes impossible.
    Imagine you changed Foo thusly:
    static Foo<?> foo = new Foo<String>(String.class);
    static void apply(Object obj) {
    foo.handle(foo.cast(obj));
    }And then used it like this:
    public class GT7 {
    public static void main(String[] args) {
    new Thread(new Runnable() {
    public void run() {
    Foo.foo = new Foo<Integer>(Integer.class);
    }).start();
    Foo.apply("Hello!");
    }How's the compiler supposed to figure that one out?Yes, if there is a race condition the compiler obviously can't assume "foo" won't change. But that's not the case in the original program.. foo is a local variable. A compiler could (with sufficient work) prove this to itself. This is not one of those an impossible Turing-complete scenarios like you sometimes see with "uninitialized variable" errors where the variable actually is always initialized.
    I'm not saying that it's necessarily worth the effort to implement this in the compiler. My only point is that this was strictly a language/compiler design choice -- and a reasonable one. But there's also nothing wrong with the "intent" of the program, even if the compiler doesn't "get it".

  • How come this sound only plays once?

    Here is a program that illustrates what I am doing:
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.sound.sampled.*;
    public class soundApp extends JFrame
        JButton button;                
        Clip clip;
        public soundApp()
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setSize(300,300);
            File file = new File("tada.wav"); 
            try
                AudioInputStream audiosource = AudioSystem.getAudioInputStream(file);
                DataLine.Info info =
                    new DataLine.Info(Clip.class, audiosource.getFormat());
                clip = (Clip)AudioSystem.getLine(info);  
                clip.open(audiosource);
            catch(UnsupportedAudioFileException e){}
            catch(LineUnavailableException e){}
            catch(IOException e){}
            button = new JButton("Play sound");
            button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e){
                if(e.getActionCommand().equals("Play sound"))
                    clip.start();   //HERE IS WHERE I START IT....sorry for caps.
            Container contentpane = getContentPane();
            contentpane.add(button);
            setVisible(true);
      public static void main(String[] args)
          soundApp soundapp = new soundApp();
    }How come the clip only plays once?

    well the answer is simple, because once the clip will stop the sound will stop too. you have not used any loop or anything that shows that the clip should go on forever. you can give some condition like play the clip unless some other button is pressed or some othe action is performed or so on. just use while or any or iterative or conditional statement to get your ay out.

  • What is "Arrow" and how does this programs relate to Windows/BootCamp?

    Hi Everyone,
    On the following YouTube video:
    http://www.youtube.com/watch?v=DxMFCksO0Ps
    When he is talking of the official bootcamp support, he mentions Arrow and other programs alike.
    Could someone inform me of these programs and what their roles are?
    Thanks
    Helooooo

    Hi,
    sounds to me like he's talking about the 'Eye Candy' stuff of Windows 7.
    http://www.windows7home.net/how-to-remove-the-arrows-on-the-desktop-shortcut-in- windows-7/
    But then again I might be wrong.
    Regards
    Stefan

  • How does this program group and cluster these button values into an array?

    In the attached program, there are 6 buttons in a cluster and 1 individual button. These buttons control a bunch of different relays to control power to different components of a single device. Right now the program works in that I can control the 6 buttons, the LED turns on in the board and the power is being transmitted. What I do not understand is how it is doing this.  I ran the program with the highlight execution on and at the start of the read from array component, if say I pressed button 6 and hit ok, it reads #6, where did these get defined and labled? and if i wanted to add another button/relay how do i do this? If someone could explain step by step how this is grouping the relays on the board into an array and then controling them I would really appreciate it. Thanks.
    Solved!
    Go to Solution.
    Attachments:
    Cluster to Array.vi ‏85 KB

    The #6 your seeing is the number of elements in the array not a value for the array. 
    Now for some deeper explainations.   From the code it appears that exactly 1 of 6 valves may be used and an additional valve may be in one of two possible states.
    When the program is run the cluster of buttons is initiallized to all False.  and we enter the outer while loop where a sequence structure starts.  In the first frame of the sequence we initiallize a shift register to hold the current value of "Buttons." and this loop runs unthrottled (Add a wait for next ms multiple to this loop to prevent using 100% of the CPU!) 
    For each iteration the buttons are read and if a change has occured to any value buttons that were previously True are reset to False to prevent opening more than one valve.
    When the user presses OK or stop- the current "Buttons" value is passed to the next frame.  This frame convertsthe 7 boolean values to a integer where each valve is controlled by a seperate bit of the integer (Isolation is bit 6 and bits 0-5 each control a mixing valve)
    Now I'd strongly recommend reworking the DAQmx calls- it is pointless to initiallize the task each time you want to use it- Create the task in the initialzation case and wait until the user exits to destroy the task.  And well a sequence structures are frowned on- (there are better ways to do this)
    As far as adding a relay- right now the relays are associated to the hardware by their index position in the cluster (element 1 = bit 0 etc....) to add a new valve you would need to decide what bit you would use to drive it and code in that bits' value to write a 0 in that bit.  (hint the 40 constant is realy 0x40 right-click>visable items>show radix )
    Let me know if you need further elaboration
    Jeff

  • I am trying to delete an email. However, when I highlight it, the highlight turns a very dark blue and all I can do is undelete it! How come this happens?

    I am trying to delete an email. However, recently, when I highlight the email, the highlighted area turns a very dark blue and all I can do is undelete it. The "delete" sign at the top is not visible. What causes this to happen?

    I found this link for a similar problem someone had with a Lotus Notes account. I used it to resolve my issue with a different email account (basically followed the same steps, and then looked for the particular account I needed to delete)... hope it helps!
    http://aumja24-usa.blogspot.com/2010/10/iphone-removing-lotus-notes-traveler.htm l

  • How does this program work???

    My Mac Powerbook G4 has GarageBand 3.0.4, which I have not yet used.
    Now I want to create a file which has one track entered from an aifc file
    (converted from Sibelius 4 with Wire Tap Pro). Once I have this as a GB
    file, I want to overlay a second vocal track. Haven't a clue how to do this.
    Help, help! James Johnson, Plattsburgh NY

    Thanks very much for the nudge, and I'm beginning to get the feel of it.
    One thing I don't quite "get" already: having created a real instrument track,
    why is it necessary to select a sound? I selected basic male vocal of course --
    haven't tried to record anything yet.
    Also: if I have already installed the track which is my completely composed instrumental
    of the song, why should I (or do I?) have to select a tempo and key? I am guessing that
    I don't have to do that.
    If you please, you can reply to me at [email protected] JJ

  • How does this program work on  a Mac OS-X 10.8.5?

    How does Adobe Photoshop Elements and Adobe Premiere work on a MAC OS-X 10.8.5?  Do I need additional software?

    Hi,
    The drivers for your device are available through Apple Software Update.
    Follow the steps below to install and find out how to use it on your OS:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c02911238&tmp_task=setupCategory&cc=us&dlc=en&lc...
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • When on phone, can't open screen to check text or other things without hanging up on call.How come this is happening

    If anyone knows how to fix this, please let me know.  I've only had the phone about two weeks now and this seems to be the only problem I am having.

        Let's get to the bottom of this aprylstarr! Did this just begin or did you experience this from purchase? Does anything happen if you press the menu button? Try enabling safe mode here http://vz.to/1dHYdbi test and share your results. Also please navigate to Settings>Accessibility>Check "Power button ends call" setting>Uncheck>Power the phone off/on and test. Please share. Thank you.
    TominqueBo_VZW
    Please follow us on Twitter @VZWSupport  

  • How come this doesn't work?

    for (i=0;i!=(row*col);i++){
    total+=parseFloat(eval("value"+(i+1)));
    trace(total);
    trace(parseFloat(eval("value"+(i+1))));
    total is a variable from a dynamic text box and the
    eval("value"+(i+1)) variables are from input text boxes. The
    trace(parseFloat(eval("value"+(i+1)))); displays the values entered
    in the input boxes correctly but the trace(total); displays NULL
    everytime.
    Variables row and col both = 2, and the input text values =
    random integer (entered by user).
    I'm probably missing something really stupid but i can't see
    what is wrong with this.

    Ah forget it, i just had to do total = 0; before hand, even
    though when i did this without using eval() it worked without
    having to be pre defined.

  • How come this formula doesn't work :ARRONDI((Total Total des factures÷1.149749) ; 2) ???

    I need some help to understand basic formula please...

    I am guessing you mean this formula?
    ARRONDI((Total Total des factures÷1.149749) ; 2)
    since you are using the semicolon (";") as the argument delimiter you should be using the comma as the decimal.
    so try this:
    ARRONDI((Total Total des factures÷1,149749) ; 2)

  • How come this does not work?

    String str = null, gene="";
              int count = 0;
              boolean return_proteins=true;
         while (((str = in.readLine()) != null) && return_proteins ){
                             int index = str.indexOf("gi|");
                             if (index>-1)
                                  count++;
                                  gene = str.substring(index+3);
                                  System.out.println(str.substring(index+3));
                                  //System.out.println(str.substring(str.indexOf("VALIGN=\"TOP\">") + 13));
                                  //index = str.indexOf("(nr-Homo-sapiens)");
                                  //if (index>-1)
                                       //String valign = str.substring(index+17,str.indexOf("</TD>"));
                                       //System.out.println(str.indexOf("</TD>"));
                             StringTokenizer token = new
                             StringTokenizer(str,"gi|");
                             While (token.hasMoreTokens())
                             String subStr=token.nextToken();
                                  System.out.printIn(token.nextToken+"");
                                  outfile.write(count+":" + gene +": \n");
                   }

    Each line of the following part contains errors that shall prevent your code from being compiled:While (token.hasMoreTokens())
    String subStr=token.nextToken();
    System.out.printIn(token.nextToken+"");

  • How come this isn't working

    I try to run this but it won't work.
    cArray[0].scores[0] = (Double.valueOf(jtfQuiz2.getText())).doubleValue();
    I am using 0 for the indexes just to see if I can get something in them. Then I try to see if anything has been put in them by calling :
    jtfQuizAvg.setText(String.valueOf(cArray[0].scores[0]));
    I declared an array of 50 objects like this.
    CIS[] cArray = new CIS[50];
    I have a class (CIS) in a package that I have imported. I am trying to get the scores of the individual tests in to the scores[] array found in that class I have imported.
    CIS[] cArray = new CIS[50];
    Please please help me!

    Well, you don't say what your problem actually is, other than "it won't work", but one thing you should be aware of is thatCIS[] cArray = new CIS[50]; doesn't create an array of 50 CIS objects. Rather, it creates an array that can REFERENCE 50 CIS objects. You still have to create each object as you need it. So if you are getting a NullPointerException, that's because you needcArray[0] = new CIS(); before you use cArray[0].
    HTH
    Robin

Maybe you are looking for

  • Use a remote iPad for development purposes?

    I want to allow my partner's iPad to test my apps. No problem, of course if the iPad is within connecting distance to XCode. However, the iPad is at a remote location, and my partner doesn't use a Mac. How can I authorise the device and transfer my a

  • Expiring Exchange certs on a SBS 2011 Standard server

    We have many servers running SBS 2011 standard. On one particular server (which just passed the three year mark this past weekend) we are seeing MSExchangeTransport Event ID 12015 and 12016, telling us that an internal transport certificate has expir

  • How to change the date considered for taxing purposes?

    Hello All, In the preparation for the new tax rate in Québec, I need to configure the system to consider two dates in order to proporly select the TVQ rate.  The change date as well as the current and the next rate were already set in FTXP.  But when

  • Tab order direction and table size

    Hello. I have a form with a table that should be filled by the user. The default tab order is Left to Right, and I need it to be Right to Left. I tried to set the tab order from the Tab Order tab, and it worked on the first row, but when adding rows

  • Adobe Reader Updater - Error 1402. Could not open key:

    Adobe Reader Updater, error 1402, could not open key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Opt I might have accidently discontinue. Can any body help me????