To Lecture Notes

IT 230 -- 4/15/09

 

Review Questions

  1. What is a reference variable?
    Ans: A variable that contains a reference to or address of an object.
     
  2. What does static mean? Give an example of a static property and a static method.
    Ans: static means that the property or method is invoked by the class name, not an object. DateTime.Now is an example of a static property; int.Parse is an example of a static method.
     
  3. What is the difference between these constructor calls? Ans: The first noarg constructor call creates a Random object with a seed computed from the time of day clock on the computer. The second constructor call has an argument that is the seed for the random number generator. The second object will produce the same random numbers every time the application runs. The first object will produce different random numbers everytime the application runs.
     
  4. What are the minimum and maximum random values that can be returned by these method calls. r is a reference variable for a random object. Ans: (1) min value=0, max value=2147483647; (2) min value=0, max value=64, (3) min value=1, max value=9.
     
  5. Give other ways of displaying the random numbers of Problem 4 on a web page.
    Ans: Using a Literal control, using a TextBox control, using the <%= => delimiters.
     
  6. Find the mistakes:
     
    <!- ASP.Net file with many mistakes.
    <%! Page %>
    
    <script language=C#>
    public void btnClickMe_Click(object sender, EventArgs e)
    {   txtClicks.Text++;  }
    
    <html xmlsn=http://www.w3.org/1999/xhtml>
    <head>
    <title>clickcounter2.aspx Example</title>
    <link rep=stylesheet class=css/txt href=examples.css>
    <body>
    </head>
    <h2>Find the Mistakes</h1>
    <form id=frm Main runat=server
    </form>
    <p>Random Value: 
    <asp:Literal ID=litValue Value=0 style=text-align:right></p>
    </body>
    
    Ans: Here is the corrected version:
    <!-- ASP.Net file with many mistakes. -->
    <%! Page Language=C# %>
    
    <script runat=server>
    public void btnClickMe_Click(object sender, EventArgs e)
    {   
        int n = int.Parse(txtClicks.Text);  
        n++;
        txtClicks.Text = n.ToString( );
    }
    
    <html xmlns=http://www.w3.org/1999/xhtml>>
    <head>
    <title>clickcounter2.aspx Example</title>
    <link rep=stylesheet class=css/txt href=examples.css>
    </head>
    
    <body>
    <h2>Find the Mistakes</h2>
    <form id=frmMain runat=server>
    
    <p>Random Value: 
    <asp:Literal ID=litValue Value=0 style=text-align:right></p>
    
    <p> <asp:Button ID=btnClickMe Text=Click Me
            OnClick=btnClickMe_Click />
    
    </form>
    </body>
    </html>
    

 

Structured Programming

 

HTML Controls

 

ASP.Net Web Controls

 

Project 3