SlideShare una empresa de Scribd logo
1 de 6
Descargar para leer sin conexión
TO Buy the Tutorial Visit Our Website
Select the best answer.
1: The .class extension on a file means that the file
a.contains Java source code.
b.contains HTML.
c.is produced by the Java compiler (javac).
d.contains a machine specific executable image.
2: Which command compiles the Java source code file Welcome.java?
a.cd Welcome.java
b.javac Welcome.java
c.java Welcome.java
d.compile Welcome.java
3: A(n) ________ enables a program to read data from the user.
a.printf
b.import declaration
c.Scanner
d.main routine
4: Which of the following is a Scanner method?
a.nextLine
b.nextText
c.nextWord
d.readNext
5: Every Java application is required to have
a. at least one public static method.
b.at least one data member.
c. a String variable which holds the name of the application.
d.a content pane and several GUI components.
6: Which of the following statements about creating arrays and
initializing their elements is false?
a. The new keyword should be used to create an array.
b. When an array is created, the number of elements must be placed in
square brackets following the type of element being stored.
c. The elements of an array have unknown values just after the array has
been created.
d. A for loop is an excellent way to initialize the elements of an array.
7: Assume the following class declaration.
class MyClass
{
int a;
String q;
public void firstMethod()
{
int b, ;
* 7;
+ c * a;
}
}
Mark the following statements as TRUE or FALSE.
q is a reference variable which refers to the empty string. __TRUE___ b
and c are local variables. ___TRUE____ a, b, and c are primitive data
types. ___FALSE____ MyClass is a Java application. ___FALSE____
8: Which statement below could be used to randomly select a state from
an array which contains exactly 50 strings which are the names of the
states?
1 + ( int ) ( Math.random( ) * 49 ); ( int ) ( Math.random( ) * 51 ); ( int )
( Math.random( ) * 50 ); 1 + ( int ) ( Math.random( ) * 50 );
9: To draw a single line from (0, 15) to (20, 25), call the method
_________ of the Graphics class in the paintComponent method.
a.drawLine( 0, 15, 20, 25 );
b.drawString( "single line", 0, 15 );
c.drawLine( 0, 15, 20, 10 );
d.drawLine( 15, 0, 25, 20 );
10: In the Java graphics system, coordinate units are measured in
________.
a.dots
b.pixels
c.points
d.inches
11: Which is a correct way to invoke the static method sqrt of the Math
class?
a.sqrt( 900 );.
b.math.sqrt( 900 );.
c.Math.sqrt( 900 );.
d.Math Math(); math.sqrt( 900 );.
12: When an object is concatenated with a String
a.a compilation error occurs.
b.a runtime error occurs.
c.the object’s toString method is implicitly called to obtain the String
representation of the object.
d.the object’s class name is used.
13: What do the following statements do?
double array[];
double[ 14 ];
a. Creates a double array containing 13 elements.
b.Creates a double array containing 14 elements.
c. Creates a double array containing 15 elements.
d. Declares but does not create a double array.
14: Consider the class below:
public class Test
{
public static void main( String args[] )
{
int a[];
int[ 10 ];
for ( int ; i <a.length; i++ )
a[ i ] = i + 1 * 2;
int ;
for ( int ; i <a.length; i++ )
result += a[ i ];
System.out.printf( "Result is: %dn", result );
} // end main
} // end class Test
The output of this Java program will be
a. Result is: 62
b. Result is: 64
c. Result is: 65
d. Result is: 67
15: Which method call converts the value in variable stringVariable to
an integer?
a. Convert.toInt( stringVariable )
b. Convert.parseInt( stringVariable )
c. Integer.parseInt( stringVariable )
d.Integer.toInt( stringVariable )
16: Which of the following is the method used to display a dialog box to
gather input?
a. showMessageDialog
b. getInput
c. inputDialog
d. showInputDialog
17: provides the basic attributes and behaviors of a window—a title bar
at the top of the window, and buttons to minimize, maximize and close the
window.
a. JLabel
b. JFrame
c. JSwing
d. JWindowControl
18: Which of the following does not generate an event?
a. Typing in a text field.
b. Clicking on a button.
c. Viewing the text in a label.
d. Moving the mouse.
19: When the user presses Enter in a JTextField, the GUI component
generates an , which is processed by an object that implements the
interface .
a. ActionEvent, ActionListener
b. ActionEvent, ActionEventListener
c. TextEvent, TextListener
d. TextEvent, TextEventListener
202: When the user clicks a JCheckBox, a(n) occurs.
a. CheckedEvent
b. ButtonEvent
c. ItemEvent
d. ActionEvent
21: Which method determines if a JRadioButton is selected?
a. isSelected
b. getSelected
c. selected
d. none of the above
22: The logical relationship between radio buttons is maintained by
objects of what class?
a. MutualExclusionGroup
b. RadioButtonGroup
c. Group
d. ButtonGroup
23: Which layout manager is the default for JPanel?
a. FlowLayout
b. BorderLayout
c. GridLayout
d. none of the above
24. A Java interface
a. must contain only public abstract methods.
b. can be implemented by any number of Java classes.
c. reference can refer to objects of any class which implements the
interface.
d. all of the above
25. Writing an application which handles mouse events can be done by
a. having a GUI class implement the KeyListener interface.
b. creating an inner class which extends the MouseAdapter class.
c. adding mouse functionality to the paintComponent method.
d. all of the above
26. Write a Java statement using printf to output the value of Math.PI,
showing 5 digits after the decimal point.
27. Write a Java statement that declares a class called MyDrawingPanel
that inherits from the JPanel class. Do not declare any methods or
member variables in this class.
28. Class Cap has been defined as a base class, and class BaseballCap
inherits from class Cap. Is the following Java statement legal? Explain
why or why not.
29. Write a few lines of code that would place 2 radio buttons labeled on
and off side by side into the top part of a JFrame based window. Assume
that the code you are writing is inside the constructor of an application
which inherits from JFrame. Declare any variables that you need. You
should only need 6-8 lines of code.
30. This Java application is supposed to do the following. There are 2
text fields for user input. The first is used to input a voltage value. The
second is used to input a resistance value in ohms. All values are floating
point values. The user clicks a button to perform a calculation. One
button causes the program to calculate and display the current flowing
through the resistor, / R. Another button causes the program to calculate
the power being dissipated by the resistor, * V. The result of the selected
calculation is displayed in a single output text area. The output string
should say something like this: “10 volts dropped across 1000 ohms
creates 0.1 amps.” Clicking of a button generates the event which causes
the program to do the selected calculation and update the output area.
The user interface has already been setup in the class that follows. Your
job is to implement the ButtonHandler nested inner class which handles
button events, does the requested calculation and displays the
appropriate result.
b. can be implemented by any number of Java classes.
c. reference can refer to objects of any class which implements the
interface.
d. all of the above
25. Writing an application which handles mouse events can be done by
a. having a GUI class implement the KeyListener interface.
b. creating an inner class which extends the MouseAdapter class.
c. adding mouse functionality to the paintComponent method.
d. all of the above
26. Write a Java statement using printf to output the value of Math.PI,
showing 5 digits after the decimal point.
27. Write a Java statement that declares a class called MyDrawingPanel
that inherits from the JPanel class. Do not declare any methods or
member variables in this class.
28. Class Cap has been defined as a base class, and class BaseballCap
inherits from class Cap. Is the following Java statement legal? Explain
why or why not.
29. Write a few lines of code that would place 2 radio buttons labeled on
and off side by side into the top part of a JFrame based window. Assume
that the code you are writing is inside the constructor of an application
which inherits from JFrame. Declare any variables that you need. You
should only need 6-8 lines of code.
30. This Java application is supposed to do the following. There are 2
text fields for user input. The first is used to input a voltage value. The
second is used to input a resistance value in ohms. All values are floating
point values. The user clicks a button to perform a calculation. One
button causes the program to calculate and display the current flowing
through the resistor, / R. Another button causes the program to calculate
the power being dissipated by the resistor, * V. The result of the selected
calculation is displayed in a single output text area. The output string
should say something like this: “10 volts dropped across 1000 ohms
creates 0.1 amps.” Clicking of a button generates the event which causes
the program to do the selected calculation and update the output area.
The user interface has already been setup in the class that follows. Your
job is to implement the ButtonHandler nested inner class which handles
button events, does the requested calculation and displays the
appropriate result.

Más contenido relacionado

Destacado

Comp 328 final guide (devry)
Comp 328 final guide (devry)Comp 328 final guide (devry)
Comp 328 final guide (devry)sukeshsuresh189
 
Rétro camping car
Rétro camping carRétro camping car
Rétro camping carJoyeux Nain
 
19: When the user presses Enter in a JTextField, the GUI component generates ...
19: When the user presses Enter in a JTextField, the GUI component generates ...19: When the user presses Enter in a JTextField, the GUI component generates ...
19: When the user presses Enter in a JTextField, the GUI component generates ...sukeshsuresh189
 
21: Which method determines if a JRadioButton is selected?
21: Which method determines if a JRadioButton is selected?21: Which method determines if a JRadioButton is selected?
21: Which method determines if a JRadioButton is selected?sukeshsuresh189
 
23: Which layout manager is the default for JPanel?
23: Which layout manager is the default for JPanel?23: Which layout manager is the default for JPanel?
23: Which layout manager is the default for JPanel?sukeshsuresh189
 
5: Every Java application is required to have
5: Every Java application is required to have5: Every Java application is required to have
5: Every Java application is required to havesukeshsuresh189
 
202: When the user clicks a JCheckBox, a(n) occurs.
202: When the user clicks a JCheckBox, a(n) occurs.202: When the user clicks a JCheckBox, a(n) occurs.
202: When the user clicks a JCheckBox, a(n) occurs.sukeshsuresh189
 

Destacado (8)

Comp 328 final guide (devry)
Comp 328 final guide (devry)Comp 328 final guide (devry)
Comp 328 final guide (devry)
 
Rétro camping car
Rétro camping carRétro camping car
Rétro camping car
 
19: When the user presses Enter in a JTextField, the GUI component generates ...
19: When the user presses Enter in a JTextField, the GUI component generates ...19: When the user presses Enter in a JTextField, the GUI component generates ...
19: When the user presses Enter in a JTextField, the GUI component generates ...
 
21: Which method determines if a JRadioButton is selected?
21: Which method determines if a JRadioButton is selected?21: Which method determines if a JRadioButton is selected?
21: Which method determines if a JRadioButton is selected?
 
23: Which layout manager is the default for JPanel?
23: Which layout manager is the default for JPanel?23: Which layout manager is the default for JPanel?
23: Which layout manager is the default for JPanel?
 
5: Every Java application is required to have
5: Every Java application is required to have5: Every Java application is required to have
5: Every Java application is required to have
 
202: When the user clicks a JCheckBox, a(n) occurs.
202: When the user clicks a JCheckBox, a(n) occurs.202: When the user clicks a JCheckBox, a(n) occurs.
202: When the user clicks a JCheckBox, a(n) occurs.
 
David Hawks Presentation
David Hawks PresentationDavid Hawks Presentation
David Hawks Presentation
 

Similar a 13: What do the following statements do?

Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guidekrtioplal
 
C programming session 08
C programming session 08C programming session 08
C programming session 08Vivek Singh
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docxrosemarybdodson23141
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
QUESTION 1Give two examples of Operating Systems.QUESTION .docx
QUESTION 1Give two examples of Operating Systems.QUESTION .docxQUESTION 1Give two examples of Operating Systems.QUESTION .docx
QUESTION 1Give two examples of Operating Systems.QUESTION .docxIRESH3
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comCIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comKeatonJennings91
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principlesmoduledesign
 
Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeansHuu Bang Le Phan
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principlesmoduledesign
 

Similar a 13: What do the following statements do? (16)

Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guide
 
selenium_master.pdf
selenium_master.pdfselenium_master.pdf
selenium_master.pdf
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docx
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Csharp
CsharpCsharp
Csharp
 
QUESTION 1Give two examples of Operating Systems.QUESTION .docx
QUESTION 1Give two examples of Operating Systems.QUESTION .docxQUESTION 1Give two examples of Operating Systems.QUESTION .docx
QUESTION 1Give two examples of Operating Systems.QUESTION .docx
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comCIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.com
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
AdvancedJava.pptx
AdvancedJava.pptxAdvancedJava.pptx
AdvancedJava.pptx
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principles
 
Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeans
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principles
 

Más de sukeshsuresh189

22: The logical relationship between radio buttons is maintained by objects o...
22: The logical relationship between radio buttons is maintained by objects o...22: The logical relationship between radio buttons is maintained by objects o...
22: The logical relationship between radio buttons is maintained by objects o...sukeshsuresh189
 
18: Which of the following does not generate an event?
18: Which of the following does not generate an event?18: Which of the following does not generate an event?
18: Which of the following does not generate an event?sukeshsuresh189
 
17: provides the basic attributes and behaviors of a window—a title bar at th...
17: provides the basic attributes and behaviors of a window—a title bar at th...17: provides the basic attributes and behaviors of a window—a title bar at th...
17: provides the basic attributes and behaviors of a window—a title bar at th...sukeshsuresh189
 
16: Which of the following is the method used to display a dialog box to gath...
16: Which of the following is the method used to display a dialog box to gath...16: Which of the following is the method used to display a dialog box to gath...
16: Which of the following is the method used to display a dialog box to gath...sukeshsuresh189
 
15: Which method call converts the value in variable stringVariable to an int...
15: Which method call converts the value in variable stringVariable to an int...15: Which method call converts the value in variable stringVariable to an int...
15: Which method call converts the value in variable stringVariable to an int...sukeshsuresh189
 
14: Consider the class below:
14: Consider the class below:14: Consider the class below:
14: Consider the class below:sukeshsuresh189
 
12: When an object is concatenated with a String
12: When an object is concatenated with a String12: When an object is concatenated with a String
12: When an object is concatenated with a Stringsukeshsuresh189
 
11: Which is a correct way to invoke the static method sqrt of the Math class?
11: Which is a correct way to invoke the static method sqrt of the Math class?11: Which is a correct way to invoke the static method sqrt of the Math class?
11: Which is a correct way to invoke the static method sqrt of the Math class?sukeshsuresh189
 
10: In the Java graphics system, coordinate units are measured in ________.
10: In the Java graphics system, coordinate units are measured in ________.10: In the Java graphics system, coordinate units are measured in ________.
10: In the Java graphics system, coordinate units are measured in ________.sukeshsuresh189
 
Comp 328 final guide (devry)
Comp 328 final guide (devry)Comp 328 final guide (devry)
Comp 328 final guide (devry)sukeshsuresh189
 
8: Which statement below could be used to randomly select a state from an arr...
8: Which statement below could be used to randomly select a state from an arr...8: Which statement below could be used to randomly select a state from an arr...
8: Which statement below could be used to randomly select a state from an arr...sukeshsuresh189
 
7: Assume the following class declaration.
7: Assume the following class declaration.7: Assume the following class declaration.
7: Assume the following class declaration.sukeshsuresh189
 
6: Which of the following statements about creating arrays and initializing t...
6: Which of the following statements about creating arrays and initializing t...6: Which of the following statements about creating arrays and initializing t...
6: Which of the following statements about creating arrays and initializing t...sukeshsuresh189
 
4: Which of the following is a Scanner method?
4: Which of the following is a Scanner method?4: Which of the following is a Scanner method?
4: Which of the following is a Scanner method?sukeshsuresh189
 
3: A(n) ________ enables a program to read data from the user.
3: A(n) ________ enables a program to read data from the user.3: A(n) ________ enables a program to read data from the user.
3: A(n) ________ enables a program to read data from the user.sukeshsuresh189
 
1: The .class extension on a file means that the file
1:  The .class extension on a file means that the file1:  The .class extension on a file means that the file
1: The .class extension on a file means that the filesukeshsuresh189
 
Comp 328 final guide (devry)
Comp 328 final guide (devry)Comp 328 final guide (devry)
Comp 328 final guide (devry)sukeshsuresh189
 
Com 200 week 5 final paper letter of advice paper (2 papers)
Com 200 week 5 final paper letter of advice paper (2 papers)Com 200 week 5 final paper letter of advice paper (2 papers)
Com 200 week 5 final paper letter of advice paper (2 papers)sukeshsuresh189
 

Más de sukeshsuresh189 (18)

22: The logical relationship between radio buttons is maintained by objects o...
22: The logical relationship between radio buttons is maintained by objects o...22: The logical relationship between radio buttons is maintained by objects o...
22: The logical relationship between radio buttons is maintained by objects o...
 
18: Which of the following does not generate an event?
18: Which of the following does not generate an event?18: Which of the following does not generate an event?
18: Which of the following does not generate an event?
 
17: provides the basic attributes and behaviors of a window—a title bar at th...
17: provides the basic attributes and behaviors of a window—a title bar at th...17: provides the basic attributes and behaviors of a window—a title bar at th...
17: provides the basic attributes and behaviors of a window—a title bar at th...
 
16: Which of the following is the method used to display a dialog box to gath...
16: Which of the following is the method used to display a dialog box to gath...16: Which of the following is the method used to display a dialog box to gath...
16: Which of the following is the method used to display a dialog box to gath...
 
15: Which method call converts the value in variable stringVariable to an int...
15: Which method call converts the value in variable stringVariable to an int...15: Which method call converts the value in variable stringVariable to an int...
15: Which method call converts the value in variable stringVariable to an int...
 
14: Consider the class below:
14: Consider the class below:14: Consider the class below:
14: Consider the class below:
 
12: When an object is concatenated with a String
12: When an object is concatenated with a String12: When an object is concatenated with a String
12: When an object is concatenated with a String
 
11: Which is a correct way to invoke the static method sqrt of the Math class?
11: Which is a correct way to invoke the static method sqrt of the Math class?11: Which is a correct way to invoke the static method sqrt of the Math class?
11: Which is a correct way to invoke the static method sqrt of the Math class?
 
10: In the Java graphics system, coordinate units are measured in ________.
10: In the Java graphics system, coordinate units are measured in ________.10: In the Java graphics system, coordinate units are measured in ________.
10: In the Java graphics system, coordinate units are measured in ________.
 
Comp 328 final guide (devry)
Comp 328 final guide (devry)Comp 328 final guide (devry)
Comp 328 final guide (devry)
 
8: Which statement below could be used to randomly select a state from an arr...
8: Which statement below could be used to randomly select a state from an arr...8: Which statement below could be used to randomly select a state from an arr...
8: Which statement below could be used to randomly select a state from an arr...
 
7: Assume the following class declaration.
7: Assume the following class declaration.7: Assume the following class declaration.
7: Assume the following class declaration.
 
6: Which of the following statements about creating arrays and initializing t...
6: Which of the following statements about creating arrays and initializing t...6: Which of the following statements about creating arrays and initializing t...
6: Which of the following statements about creating arrays and initializing t...
 
4: Which of the following is a Scanner method?
4: Which of the following is a Scanner method?4: Which of the following is a Scanner method?
4: Which of the following is a Scanner method?
 
3: A(n) ________ enables a program to read data from the user.
3: A(n) ________ enables a program to read data from the user.3: A(n) ________ enables a program to read data from the user.
3: A(n) ________ enables a program to read data from the user.
 
1: The .class extension on a file means that the file
1:  The .class extension on a file means that the file1:  The .class extension on a file means that the file
1: The .class extension on a file means that the file
 
Comp 328 final guide (devry)
Comp 328 final guide (devry)Comp 328 final guide (devry)
Comp 328 final guide (devry)
 
Com 200 week 5 final paper letter of advice paper (2 papers)
Com 200 week 5 final paper letter of advice paper (2 papers)Com 200 week 5 final paper letter of advice paper (2 papers)
Com 200 week 5 final paper letter of advice paper (2 papers)
 

Último

Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice documentXsasf Sfdfasd
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxiammrhaywood
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...CaraSkikne1
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17Celine George
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 

Último (20)

Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice document
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 

13: What do the following statements do?

  • 1. TO Buy the Tutorial Visit Our Website Select the best answer. 1: The .class extension on a file means that the file a.contains Java source code. b.contains HTML. c.is produced by the Java compiler (javac). d.contains a machine specific executable image. 2: Which command compiles the Java source code file Welcome.java? a.cd Welcome.java b.javac Welcome.java c.java Welcome.java d.compile Welcome.java 3: A(n) ________ enables a program to read data from the user. a.printf b.import declaration c.Scanner d.main routine 4: Which of the following is a Scanner method? a.nextLine b.nextText c.nextWord d.readNext 5: Every Java application is required to have a. at least one public static method. b.at least one data member. c. a String variable which holds the name of the application. d.a content pane and several GUI components. 6: Which of the following statements about creating arrays and initializing their elements is false? a. The new keyword should be used to create an array. b. When an array is created, the number of elements must be placed in square brackets following the type of element being stored.
  • 2. c. The elements of an array have unknown values just after the array has been created. d. A for loop is an excellent way to initialize the elements of an array. 7: Assume the following class declaration. class MyClass { int a; String q; public void firstMethod() { int b, ; * 7; + c * a; } } Mark the following statements as TRUE or FALSE. q is a reference variable which refers to the empty string. __TRUE___ b and c are local variables. ___TRUE____ a, b, and c are primitive data types. ___FALSE____ MyClass is a Java application. ___FALSE____ 8: Which statement below could be used to randomly select a state from an array which contains exactly 50 strings which are the names of the states? 1 + ( int ) ( Math.random( ) * 49 ); ( int ) ( Math.random( ) * 51 ); ( int ) ( Math.random( ) * 50 ); 1 + ( int ) ( Math.random( ) * 50 ); 9: To draw a single line from (0, 15) to (20, 25), call the method _________ of the Graphics class in the paintComponent method. a.drawLine( 0, 15, 20, 25 ); b.drawString( "single line", 0, 15 ); c.drawLine( 0, 15, 20, 10 ); d.drawLine( 15, 0, 25, 20 ); 10: In the Java graphics system, coordinate units are measured in ________. a.dots b.pixels c.points d.inches 11: Which is a correct way to invoke the static method sqrt of the Math class? a.sqrt( 900 );. b.math.sqrt( 900 );. c.Math.sqrt( 900 );. d.Math Math(); math.sqrt( 900 );. 12: When an object is concatenated with a String a.a compilation error occurs.
  • 3. b.a runtime error occurs. c.the object’s toString method is implicitly called to obtain the String representation of the object. d.the object’s class name is used. 13: What do the following statements do? double array[]; double[ 14 ]; a. Creates a double array containing 13 elements. b.Creates a double array containing 14 elements. c. Creates a double array containing 15 elements. d. Declares but does not create a double array. 14: Consider the class below: public class Test { public static void main( String args[] ) { int a[]; int[ 10 ]; for ( int ; i <a.length; i++ ) a[ i ] = i + 1 * 2; int ; for ( int ; i <a.length; i++ ) result += a[ i ]; System.out.printf( "Result is: %dn", result ); } // end main } // end class Test The output of this Java program will be a. Result is: 62 b. Result is: 64 c. Result is: 65 d. Result is: 67 15: Which method call converts the value in variable stringVariable to an integer? a. Convert.toInt( stringVariable ) b. Convert.parseInt( stringVariable ) c. Integer.parseInt( stringVariable ) d.Integer.toInt( stringVariable ) 16: Which of the following is the method used to display a dialog box to gather input? a. showMessageDialog b. getInput
  • 4. c. inputDialog d. showInputDialog 17: provides the basic attributes and behaviors of a window—a title bar at the top of the window, and buttons to minimize, maximize and close the window. a. JLabel b. JFrame c. JSwing d. JWindowControl 18: Which of the following does not generate an event? a. Typing in a text field. b. Clicking on a button. c. Viewing the text in a label. d. Moving the mouse. 19: When the user presses Enter in a JTextField, the GUI component generates an , which is processed by an object that implements the interface . a. ActionEvent, ActionListener b. ActionEvent, ActionEventListener c. TextEvent, TextListener d. TextEvent, TextEventListener 202: When the user clicks a JCheckBox, a(n) occurs. a. CheckedEvent b. ButtonEvent c. ItemEvent d. ActionEvent 21: Which method determines if a JRadioButton is selected? a. isSelected b. getSelected c. selected d. none of the above 22: The logical relationship between radio buttons is maintained by objects of what class? a. MutualExclusionGroup b. RadioButtonGroup c. Group d. ButtonGroup 23: Which layout manager is the default for JPanel? a. FlowLayout b. BorderLayout c. GridLayout d. none of the above 24. A Java interface a. must contain only public abstract methods.
  • 5. b. can be implemented by any number of Java classes. c. reference can refer to objects of any class which implements the interface. d. all of the above 25. Writing an application which handles mouse events can be done by a. having a GUI class implement the KeyListener interface. b. creating an inner class which extends the MouseAdapter class. c. adding mouse functionality to the paintComponent method. d. all of the above 26. Write a Java statement using printf to output the value of Math.PI, showing 5 digits after the decimal point. 27. Write a Java statement that declares a class called MyDrawingPanel that inherits from the JPanel class. Do not declare any methods or member variables in this class. 28. Class Cap has been defined as a base class, and class BaseballCap inherits from class Cap. Is the following Java statement legal? Explain why or why not. 29. Write a few lines of code that would place 2 radio buttons labeled on and off side by side into the top part of a JFrame based window. Assume that the code you are writing is inside the constructor of an application which inherits from JFrame. Declare any variables that you need. You should only need 6-8 lines of code. 30. This Java application is supposed to do the following. There are 2 text fields for user input. The first is used to input a voltage value. The second is used to input a resistance value in ohms. All values are floating point values. The user clicks a button to perform a calculation. One button causes the program to calculate and display the current flowing through the resistor, / R. Another button causes the program to calculate the power being dissipated by the resistor, * V. The result of the selected calculation is displayed in a single output text area. The output string should say something like this: “10 volts dropped across 1000 ohms creates 0.1 amps.” Clicking of a button generates the event which causes the program to do the selected calculation and update the output area. The user interface has already been setup in the class that follows. Your job is to implement the ButtonHandler nested inner class which handles button events, does the requested calculation and displays the appropriate result.
  • 6. b. can be implemented by any number of Java classes. c. reference can refer to objects of any class which implements the interface. d. all of the above 25. Writing an application which handles mouse events can be done by a. having a GUI class implement the KeyListener interface. b. creating an inner class which extends the MouseAdapter class. c. adding mouse functionality to the paintComponent method. d. all of the above 26. Write a Java statement using printf to output the value of Math.PI, showing 5 digits after the decimal point. 27. Write a Java statement that declares a class called MyDrawingPanel that inherits from the JPanel class. Do not declare any methods or member variables in this class. 28. Class Cap has been defined as a base class, and class BaseballCap inherits from class Cap. Is the following Java statement legal? Explain why or why not. 29. Write a few lines of code that would place 2 radio buttons labeled on and off side by side into the top part of a JFrame based window. Assume that the code you are writing is inside the constructor of an application which inherits from JFrame. Declare any variables that you need. You should only need 6-8 lines of code. 30. This Java application is supposed to do the following. There are 2 text fields for user input. The first is used to input a voltage value. The second is used to input a resistance value in ohms. All values are floating point values. The user clicks a button to perform a calculation. One button causes the program to calculate and display the current flowing through the resistor, / R. Another button causes the program to calculate the power being dissipated by the resistor, * V. The result of the selected calculation is displayed in a single output text area. The output string should say something like this: “10 volts dropped across 1000 ohms creates 0.1 amps.” Clicking of a button generates the event which causes the program to do the selected calculation and update the output area. The user interface has already been setup in the class that follows. Your job is to implement the ButtonHandler nested inner class which handles button events, does the requested calculation and displays the appropriate result.