SlideShare a Scribd company logo
or you can also search the tutorial on
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 )

More Related Content

PPTX
Arrays, Structures And Enums
PDF
Computer Science Sample Paper 2015
PPT
basic concepts
PDF
Sample Paper 2 Class XI (Computer Science)
PDF
Sample Paper Class XI (Informatics Practices)
PDF
Algorithms: II
PDF
Lec 6 14_aug [compatibility mode]
PDF
IP Sample paper 2 Class XI
Arrays, Structures And Enums
Computer Science Sample Paper 2015
basic concepts
Sample Paper 2 Class XI (Computer Science)
Sample Paper Class XI (Informatics Practices)
Algorithms: II
Lec 6 14_aug [compatibility mode]
IP Sample paper 2 Class XI

What's hot (20)

PDF
04. constructor & destructor
PPTX
11. Objects and Classes
PPTX
Types of Constructor in C++
PDF
Constructors and Destructors
PDF
Algorithms: I
PDF
Intake 38 data access 3
PPTX
Templates presentation
PPTX
Java Foundations: Objects and Classes
PDF
Functional programming's relentless bug hunter claire
PDF
Intake 38 5 1
DOC
Java programming lab assignments
PDF
Computer science ms
PDF
Intake 38 5
DOCX
C++ Template
PPTX
1.2 matlab numerical data
PDF
Intake 37 linq1
PPTX
classes & objects in cpp overview
PDF
Ds lab handouts
PPT
Templates
PPT
C++ Returning Objects
04. constructor & destructor
11. Objects and Classes
Types of Constructor in C++
Constructors and Destructors
Algorithms: I
Intake 38 data access 3
Templates presentation
Java Foundations: Objects and Classes
Functional programming's relentless bug hunter claire
Intake 38 5 1
Java programming lab assignments
Computer science ms
Intake 38 5
C++ Template
1.2 matlab numerical data
Intake 37 linq1
classes & objects in cpp overview
Ds lab handouts
Templates
C++ Returning Objects
Ad

Viewers also liked (20)

PDF
إصلاح الأفراد والمجتمعات في الإسلام
PPTX
Ifan efendi power piont.
PPTX
Lecture 10-cs648=2013
PPTX
digi-pack deconstruction
PPSX
Dịch vụ Premium SEO _Cty CSA
PPT
Handbag hooks-wholesale
PPTX
Lecture 15
PDF
Ghid ANAF
PDF
Jee advanced-2014-paper-1-code-2
PPTX
PPTX
Gw melek politik
PDF
Республика Цвета - портфолио 2010 г
PDF
Stages of lung cancer
PDF
Obligatii activ indep
PPTX
Salud ocupacional copaso
PDF
11671 physicspaper1
PPTX
Evaluation questionmedia
PDF
كيف يحبك الله
PDF
Tabel comparativ OG 4/2015
PDF
بنو إسرائيل ووعد الآخرة لفضيلة الشيخ فوزى محمد أبوزيد
إصلاح الأفراد والمجتمعات في الإسلام
Ifan efendi power piont.
Lecture 10-cs648=2013
digi-pack deconstruction
Dịch vụ Premium SEO _Cty CSA
Handbag hooks-wholesale
Lecture 15
Ghid ANAF
Jee advanced-2014-paper-1-code-2
Gw melek politik
Республика Цвета - портфолио 2010 г
Stages of lung cancer
Obligatii activ indep
Salud ocupacional copaso
11671 physicspaper1
Evaluation questionmedia
كيف يحبك الله
Tabel comparativ OG 4/2015
بنو إسرائيل ووعد الآخرة لفضيلة الشيخ فوزى محمد أبوزيد
Ad

Similar to Comp 328 final guide (20)

PDF
Java MCQ Important Questions and Answers
PDF
ITI COPA Java MCQ important Questions and Answers
DOC
202: When the user clicks a JCheckBox, a(n) occurs.
DOC
22: The logical relationship between radio buttons is maintained by objects o...
DOC
17: provides the basic attributes and behaviors of a window—a title bar at th...
DOC
7: Assume the following class declaration.
DOC
3: A(n) ________ enables a program to read data from the user.
DOC
10: In the Java graphics system, coordinate units are measured in ________.
DOC
19: When the user presses Enter in a JTextField, the GUI component generates ...
DOC
18: Which of the following does not generate an event?
DOC
12: When an object is concatenated with a String
DOC
21: Which method determines if a JRadioButton is selected?
DOC
5: Every Java application is required to have
DOC
15: Which method call converts the value in variable stringVariable to an int...
DOC
8: Which statement below could be used to randomly select a state from an arr...
DOC
1: The .class extension on a file means that the file
DOC
11: Which is a correct way to invoke the static method sqrt of the Math class?
DOC
16: Which of the following is the method used to display a dialog box to gath...
DOC
4: Which of the following is a Scanner method?
DOC
6: Which of the following statements about creating arrays and initializing t...
Java MCQ Important Questions and Answers
ITI COPA Java MCQ important Questions and Answers
202: When the user clicks a JCheckBox, a(n) occurs.
22: The logical relationship between radio buttons is maintained by objects o...
17: provides the basic attributes and behaviors of a window—a title bar at th...
7: Assume the following class declaration.
3: A(n) ________ enables a program to read data from the user.
10: In the Java graphics system, coordinate units are measured in ________.
19: When the user presses Enter in a JTextField, the GUI component generates ...
18: Which of the following does not generate an event?
12: When an object is concatenated with a String
21: Which method determines if a JRadioButton is selected?
5: Every Java application is required to have
15: Which method call converts the value in variable stringVariable to an int...
8: Which statement below could be used to randomly select a state from an arr...
1: The .class extension on a file means that the file
11: Which is a correct way to invoke the static method sqrt of the Math class?
16: Which of the following is the method used to display a dialog box to gath...
4: Which of the following is a Scanner method?
6: Which of the following statements about creating arrays and initializing t...

More from krtioplal (12)

DOCX
Comp 328 week 6 lab 6
DOCX
Comp 328 week 4 midterm exam
DOCX
Comp 328 week 4 lab 4
DOCX
Comp 328 week 3 lab 3
DOCX
Comp 328 week 2 lab 2
DOCX
Comp 328 week 1 lab 1
DOCX
Comp 328 entire course
DOCX
Comp 328 week 5 lab 5
DOCX
Abs 200 week 5 dq 1 global issues
DOCX
Abs 200 week 3 step one of final paper
DOCX
Abs 200 week 2 dq 1 empowerment
DOCX
Abs 200 final guide
Comp 328 week 6 lab 6
Comp 328 week 4 midterm exam
Comp 328 week 4 lab 4
Comp 328 week 3 lab 3
Comp 328 week 2 lab 2
Comp 328 week 1 lab 1
Comp 328 entire course
Comp 328 week 5 lab 5
Abs 200 week 5 dq 1 global issues
Abs 200 week 3 step one of final paper
Abs 200 week 2 dq 1 empowerment
Abs 200 final guide

Recently uploaded (20)

PDF
Insiders guide to clinical Medicine.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Cell Types and Its function , kingdom of life
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Classroom Observation Tools for Teachers
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Insiders guide to clinical Medicine.pdf
01-Introduction-to-Information-Management.pdf
Complications of Minimal Access Surgery at WLH
Supply Chain Operations Speaking Notes -ICLT Program
Cell Types and Its function , kingdom of life
Module 4: Burden of Disease Tutorial Slides S2 2025
PPH.pptx obstetrics and gynecology in nursing
Classroom Observation Tools for Teachers
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Basic Mud Logging Guide for educational purpose
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Final Presentation General Medicine 03-08-2024.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Microbial disease of the cardiovascular and lymphatic systems
STATICS OF THE RIGID BODIES Hibbelers.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

Comp 328 final guide

  • 1. or you can also search the tutorial on 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.
  • 2. 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?
  • 3. 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.
  • 4. 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 )