Select this to skip to main content [CSUSB] >> [CNS] >> [Comp Sci Dept] >> [R J Botting] >> [CSci620] >> 12 [Source]
[Index] [Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Search] [Grading]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13]
Thu May 6 15:19:20 PDT 2004


    CS620 Session 12 Java102


      [ 11.html ]


      Study pp143-158 of the text book in Java. Bring questions and notes to class.


        Java in lab and and in Practice

        Stacks in Java

        extends and implements


        Non-Recursive Syntax Analysis


        Promise vs Results. Part of my research area: [ bib.php?search=reuse.*object%7Cobject.*reuse ]

      . . . . . . . . . ( end of section Topics) <<Contents | Index>>


        When a class implements an interface must it implement all the functions in the interface?

        Yes. An interface is no more than a list of functions that a class provides. The compiler will reject classes that don't define every function that are in the interfaces they implement.

        What is the structure of type Object in Java

        See [ Object.html ] for the details. It does provide a form of ad hoc polymorphism by allowing collections to hold any kind/type of Object.

        There are a collection of methods that apply to all Objects: clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait plus a constructor.

        How do real events connect to mouseXxxx methods?

        The library java.awt.event.* essentially contains the software connection be ween the hardware and the method. The hardware typically send signals to the computer that interrupt it via the operating system. The event is created by the Java system and sent to the correct method.

        Figure 6.8 tries to show this plus the method handling the incoming message and handing control back to the in erupted process.

        Should an inheriting class only over-ride base-class functions and not add any new ones?

        No. One of the main purposes of inheritance is to add new functions.

        For example we often have a parent class providing part of the functionality that we want, and the child class supplies another part of it.

        In a framework the parent class has abstract methods and classes that must be provided for the result to be useful.

        Can we add polymorphism to Java?

        No. It has polymorphism already. It takes effort to defeat it in Java.

        How can we safely inherit from nay classes?

        You can't! If to classes have different functions with the same signature then it is hard to figure out which should be executed.

        But in Java we can implement (inherit) many interfaces safely. An interface names functions but does not provide what they do. So you can not get conflicting behaviors. The behavior is provided by the child class that implements the functions. So it doesn't matter if two interface both ask us to implement foo(), we provide the single unambiguous response.

        What is System in System.out.println()?

        System is a Java Class that contains information and objects related to the operating system under which the JVM is running. For more information go to [ System.html ] in Sun's documentation.

        Why is an Applet self-contained?

        An Applet executes in a sandbox or womb. It can not access parts of the system it is running on unless they are in the sandbox. So the program runs in a sealed environment -- it is self-contained.

        In Figure 6.8 What is the "Interrupted Routine"?

        When the user reaches for the mouse and clicks it the computer will be busy. The Java program will be doing something, and this something is interrupted by the mouse clicking or moving. Since it is a program or routine, the result is an "interrupted routine".

        Explain Figure 6.8

        This shows a sequence of events. Each event is an arrow. The numbers on the arrows show the sequence of events and the arrows show the flow of control. Thus (1) the mouse interrupts the processor which send a mouseEvent to Java. (2) Java stops whatever it was doing (Interrupted routine) and passes control (3) to a Mouse handler. This triggers the redrawing of the screen (5) and hands back control to the previously interrupted routine.

        How does the Java Virtual Machine and Java Runtime Environment relate?

        The Java Runtime Environment is made up of the Java Virtual Machine plus the loaded classes. (I think).

        Compare the Common Language Run-time and the JVM.

        The JVM is designed to support Java and runs on any operating system or hardware. Thus one language operates on many systems.

        The CLR provides a cross-language platform for many languages and runs mainly on Microsoft operating systems. An language can be adjusted to work with it on one set of systems.

        What is the smallest HTML page that contain an applet.

        This is left for lab work.

        Should we use /share/java1.1.4.1/.... or /share/j2sdk1.4.1/.... in the labs?

        Whichever works. On some machines/accounts the programs seem to do nothing for ever. Once you know which works for you you can add the /share/..../bin to your PATH. Do this carefully! Also, put it before the /share/bin entry in the PATH -- /share/bin has commands that link to older broken/dismantled versions of Java:-(

        The chapter implies that import and extends are similar. Is this true?

        No. import statements are freestanding statements at the start of a file and list any remote packages that are needed to compile/run the code in the file. The extends word is used as part of a class declaration:
         		class MyClass extends MyParent ....{....}
        Do not use 'import' in a class header!

      . . . . . . . . . ( end of section Questions) <<Contents | Index>>


      Experiments with Java Applications [ lab12.html ]


      Study pp158-168 Concurrency [ 13.html ]

    . . . . . . . . . ( end of section CS620 Session 12 Java102) <<Contents | Index>>


  1. BNF::="Backus-Naur Form", for syntax and grammar, developed by Backus and Naur.
  2. EBNF::="Extended " BNF.
  3. HTML::= "HyperText Markup Language", used on the WWW.
  4. HTML_page::syntax= "<HTML>" head body.
  5. Java::="An " OO " Language from Sun".
  6. LISP::= "LISt Processing Language".
  7. LRM::="Language Reference Manual".
  8. OO::="Object-Oriented".
  9. Prolog::="Programming in Logic".
  10. TBA::="To Be Announced".
  11. UML::="Unified Modeling Language".
  12. URL::=Universal_Resource_Locator,
  13. Universal_Resource_Locator::syntax= protocol ":" location, where
    1. protocol::= "http" | "ftp" | "mailto" | ... ,
    2. location::= O( "//" host) O(pathname).

    (End of Net)
  14. WWW::= See, index to web site for this class.
  15. XBNF::="eXtreme" BNF, developed by the teacher from EBNF, designed to ASCII input of syntax, semantics, and other formal specifications.

Formulae and Definitions in Alphabetical Order