Point out the errors.

Q18. Point out the errors in the following program:

int main()

{

            cout<<”Enter variable”;

            cin>>var

            sqrs=var*var

            cout<<”The square is”<<sqrs;

Ans.

  1. The header file iostream.h has not been included.
  2. The variables var and sqrs have not been declared before using them.
  3. The statements cin>>var and sqrs=var*var have not been terminated by;
  4. The return statement of main() is missing.
  5. The closing bracket ‘}’ is missing.

Complete The Incomplete Sentences.

Q16. Complete the following incomplete sentences:

  • Stream extraction operator looks like ______ and it says “______”.
  • Stream insertion operator looks like _____and it says “_____”.
  • cin and cout are _____, not _____.

Ans. 

  • Stream extraction operator looks like >>and it says “extract the next value from the stream named cin and assign to the next-named variable”.
  • Stream insertion operator looks like << and it says “insert the value that follows into the stream named cout”.
  • cin and cout are stream objects, not keywords.

Count Lowest to Highest.

Q18. Design a Java Netbeans 6.5.1 GUI application having interface as shown below :

 The loop for the frame should print numbers from lowest to highest on the basis of given two numbers, upon clicking at “Count” button.

Sol:

Type the following code by double clicking jButton2, button, below the line that says, ‘// TODO add your handling code here’

 

 

int num1,num2;

num1=Integer.parseInt(jTextField1.getText()); Read More …

What method would you use, to simulate button’s click event, without any mouse activity

Q16. What method would you use, in order to simulate a button’s (namely OKBtn) click event, without any mouse activity from user’s side?

Ans. OKBtn.doClick();

What command do you need to write in actionPerformed() event handler of button, in order to make it exit button

Q15. What command do you need to write in actionPerformed() event handler of button, in order to make it exit button?

Ans. System.exit(0);

Component Class Of Panel.

Q12. Name the component class of panel. Also name some properties along with their purpose of this class.

Ans. The component class of a panel is JPanel. Some properties class are:

background: sets the background color of panel,

border: specifies the type of border for the panel,

toolTipText: sets the text for the toolTip.