0% found this document useful (0 votes)
13K views6 pages

Quiz4 1

This document contains a 15 question quiz about Java programming fundamentals including classes, methods, packages, and imports. It covers topics like how methods allow classes to share behaviors, when to write methods, how to instantiate objects using the new keyword, valid import statements, and package names. The questions test understanding of basic Java concepts through multiple choice questions with single or multiple correct answers.

Uploaded by

Yulia Kendengis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13K views6 pages

Quiz4 1

This document contains a 15 question quiz about Java programming fundamentals including classes, methods, packages, and imports. It covers topics like how methods allow classes to share behaviors, when to write methods, how to instantiate objects using the new keyword, valid import statements, and package names. The questions test understanding of basic Java concepts through multiple choice questions with single or multiple correct answers.

Uploaded by

Yulia Kendengis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

Section 4 Quiz 1 - L1-L2

(Answer all questions in this section)

1. Methods allow all instance of a class to share same behaviors.


Mark for Review
(1) Points

True (*)

False

Correct Correct

2. You�re designing banking software and need to store 10000


customer accounts with information on the accountholder�s name, balance, and
interest rate. The best approach is store 30000 separate variables in the main
method. Mark for Review
(1) Points

True

False (*)

Correct Correct

3. Which of the following two operations are appropriate for the


main method? Mark for Review
(1) Points

(Choose all correct answers)

Assigning memory to the variables

Calling local variables declared within a class�s method

Creating instances of objects (*)

Calling an instance object�s field and methods. (*)

Correct Correct

4. How many arguments does the following method accept?


public void simpleInterest(double principal, int noofYears, double interestRate){
System.out.println(�The interest rate is � +interestRate );
}
Mark for Review
(1) Points

3 (*)

Correct Correct

5. In Java, methods usually hold the properties of an object. Mark


for Review
(1) Points

True

False (*)

Correct Correct
Section 4 Quiz 1 - L1-L2
(Answer all questions in this section)

6. Which of the following scenarios would be ideal for writing a


method? Mark for Review
(1) Points

When you don�t find similar lines of code to describe an object�s behavior.

When you don�t want to repeat similar lines of code to describe an object�s
behavior. (*)

For every five to six lines of code.

To group similar data types together


Correct Correct

7. void type methods don�t return any values Mark for Review
(1) Points

True (*)

False

Correct Correct

8. Object instantiation is done using what keyword? Mark for


Review
(1) Points

void

instance

System

new (*)

Correct Correct

9. Which statement is true about packages? Mark for Review


(1) Points

A package contains a group of related classes. (*)

A package makes it difficult to locate the related classes.

A package doesn�t contain a group of related classes.

Packages of the Java class library do not contain related classes.

Correct Correct

10. Import statements are placed above the class definition. Mark
for Review
(1) Points

True (*)

False

Correct Correct
Section 4 Quiz 1 - L1-L2
(Answer all questions in this section)

11. Which is a risk of using fully qualified class names when


importing? Mark for Review
(1) Points

Code readability is reduced. (*)

Memory usage is increased.

The compiler runs longer.

Performance of the code is reduced.

Incorrect Incorrect. Refer to Section 4 Lesson 2.

12. Which of the following wild card character is used to import all
the classes in a particular package? Mark for Review
(1) Points

* (*)

Correct Correct

13. Which two are valid import statements of the Scanner class? Mark
for Review
(1) Points

(Choose all correct answers)

import java.util.*; (*)

import java.util;

import java.*;

import java.util.Scanner; (*)

Correct Correct

14. Given the import statement:


import java.awt.font.TextLayout;
which is the package name? Mark for Review
(1) Points

awt.font

java.awt.font (*)

java

java.awt

Correct Correct

15. The JFrame and JOptionPane classes are in the javax.swing


package. Which two will import those classes? Mark for Review
(1) Points

(Choose all correct answers)

import javax.swing.*; (*)

import javax.swing.JOptionPane;
import javax.swing.JFrame; (*)

import javax.swing.J*;
import javax.swing;

Correct Correct

You might also like