1.
Which of the following are open standards? .OGG .DOC .BMP .ODF
Correct Answer(s)
A. OGG
D. ODF
Explanation
The correct answer is OGG and ODF. OGG is an open standard for audio file formats, while ODF is an open standard for document file formats. BMP and DOC, on the other hand, are not open standards. BMP is a raster graphics image file format owned by Microsoft, and DOC is a file format used for Microsoft Word documents.
2.
Name the assignment operator used in Java.
Correct Answer
C. =
Explanation
The assignment operator used in Java is "=" which is used to assign a value to a variable.
3.
Prachi is working with the following swing controls:
jButton, jLabel, jTextField, jCheckBox.
Suggest her any two basic methods commonly available with all the four controls mentioned above.
Correct Answer(s)
A. SeText()
B. SetVisible()
Explanation
The two basic methods commonly available with all the four swing controls mentioned above are setText() and setVisible(). The setText() method is used to set the text content of a control, such as a button or a label. The setVisible() method is used to set the visibility of a control, making it either visible or invisible.
4.
Name the control which is not directly editable during run time.
Correct Answer
A. JLabel
Explanation
The jLabel control is not directly editable during runtime. It is a non-editable component that is used to display text or images on a form. Unlike jTextArea, jCheckBox, and jRadioButton, which can be interacted with and edited by the user, the jLabel control is typically used for displaying static information or labels on a form.
5.
Observe the given code:
int ctr=10;
while(ctr>5)
{ ctr=ctr-2; }
How many times the above given loop will run?
Correct Answer
A. 3 times
Explanation
The given code initializes the variable ctr to 10. The while loop condition checks if ctr is greater than 5. Since 10 is greater than 5, the loop will run for the first time. Inside the loop, ctr is decremented by 2, so its value becomes 8. The loop condition is still true, so the loop runs for the second time. ctr is again decremented by 2, making its value 6. The loop condition is still true, so the loop runs for the third time. ctr is decremented by 2 again, making its value 4. Now, the loop condition becomes false as 4 is not greater than 5, so the loop does not run anymore. Therefore, the loop runs 3 times.
6.
What will be an output of the following code if value of variable application is 1?
switch (application)
{ case 0 : jTextField1.setText("RDBMS");
case 1 : jTextField1.setText("BROWSER");
case 2 : jTextField1.setText("OS"); break;
case 3 : jTextField1.setText("pHOTO EDITOR"); break;
default : jTextField1.setText("Application Software"); break;
Correct Answer
B. OS
Explanation
The output of the code will be "OS" because the value of the variable "application" is 1, and according to the switch statement, when the value is 1, it will execute the code block for case 1. In this case, it will set the text of the jTextField1 to "BROWSER". However, there are no break statements after each case, so the code will continue to execute the code block for case 2 as well, setting the text of jTextField1 to "OS".
7.
Shiva has placed two radio buttons on a payment form designed in NetBeans to accept a mode of payment one out of cash or card. To his surprise, during runtime, a customer is able to select both options for a single transaction. Solution for the above problem.
Correct Answer
B. Set Button group Property
Explanation
Setting the Button group property ensures that only one radio button can be selected at a time. This means that when the customer selects one option, the other option will automatically be deselected. This prevents the customer from selecting both options for a single transaction.
8.
Study the following code and answer the questions that follow:
String str="Green World, Clean World";
int len=str.length(),remain;
remain=100-len;
TextField3.setText(Integer.toString(remain)+" more characters can be entered");
Correct Answer
A. 76 more characters can be entered
Explanation
The code first calculates the length of the string "Green World, Clean World" and stores it in the variable "len". It then subtracts the length from 100 to find the remaining number of characters that can be entered. Finally, it sets the text of TextField3 to the value of "remain" concatenated with the string " more characters can be entered". Since the length of the string is 24, the value of "remain" is 100 - 24 = 76. Therefore, the correct answer is "76 more characters can be entered".
9.
Name any two methods of string class.
Correct Answer(s)
B. Length()
C. Substring()
Explanation
The given correct answer lists two methods of the string class, which are length() and substring(). The length() method is used to determine the length of a string, while the substring() method is used to extract a portion of a string based on specified indices. These methods are commonly used in string manipulation and are essential for performing various operations on strings.
10.
Name the method which implements method overloading.
Correct Answer
C. Substring()
Explanation
The method that implements method overloading in this case is substring(). Method overloading occurs when a class has multiple methods with the same name but different parameters. In the case of substring(), there are multiple versions of the method that can be called depending on the parameters provided. This allows for flexibility and versatility in how the method can be used.