Q18. Point out the errors in the following program:
cout<<”The square is”<<sqrs;
- The header file iostream.h has not been included.
- The variables var and sqrs have not been declared before using them.
- The statements cin>>var and sqrs=var*var have not been terminated by;
- The return statement of main() is missing.
- The closing bracket ‘}’ is missing.
Q17. Check the following code for possible errors:
Ans. Program requires #include<iostream.h> directive.
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 _____.
- 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.
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.
Type the following code by double clicking jButton2, button, below the line that says, ‘// TODO add your handling code here’
num1=Integer.parseInt(jTextField1.getText()); Read More …
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?
Q17.Which condition (related to container controls) every Swing GUI application must fulfill?
Ans. Every Swing GUI application must have at least one top-level container.
Q15. What command do you need to write in actionPerformed() event handler of button, in order to make it exit button?
Q14. How would you set shortcut key or access key of letter A for the button?
Ans. For setting the shortcut key or access key of a button, in its mnemonic property, we shall type:
Q13. How would you write the following text in a Label?
Ans. In the text property of the label, we shall type the following:
<html> <u> H </u> ello <BR> There.
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.