Saturday, September 27, 2014

September 28, 2014 Quiz

1. Identify all errors in the following program
/*
Program Exercises1
Attempting to display a frame window
//
import swing.JFrame;
class Exercise 1 {
      public void Mail( ){
           JFrame frame;
           frame.setVisible(TRUE);

    }

}
2. Identify all errors in the following program
//
Program Exercise 2
Attempting to display a frame of size 300 by 200 pixels.
//
import Javax.Swing.*;
class two{
        public static void main method( ){
              myFrame JFrame;
              myFrame = new JFrame( );
              myFrame.setSize(300,200);
              myFrame.setVisible( );
      }
}


3. Identify all errors in the following program
/*
Program Exercise3
Attempting to display the number of characters in a given input.
*/
class three{
     public static void main( ) {
         String input;
        input=JOptionPane("input:");
    JOptionPane.showMessageDialog(null, "Input has " + input.length( ) + "characters");
   }
}


4. For each of these expressions, determine its result. Assume the value of text is a string Java Programming.
String text = "Java Programming";
a.) text.substring(0,4);
b.) text.length( );
c.) text.substring(8,12);
d.) text.substring(0,1) + text.substring(7,9)
e.)text.substring(5,6) + text.substring(text.length()-3,text.length( ))


5.) Write a Java application that displays the two messages I CAN DESIGN AND I CAN PROGRAM, using two separate lines.


No comments:

Post a Comment