0% found this document useful (0 votes)
4 views13 pages

Multifuncional Para Java

The document contains a series of interactive quiz questions and answers related to Java SE fundamentals, covering topics such as object-oriented programming, Java Development Kit components, and various Java concepts including methods, variables, and exceptions. Each lesson includes multiple choice, drag and drop, and fill-in-the-blank questions to assess understanding of Java programming principles. The document serves as a comprehensive resource for learners to test their knowledge and reinforce their understanding of Java programming concepts.

Uploaded by

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

Multifuncional Para Java

The document contains a series of interactive quiz questions and answers related to Java SE fundamentals, covering topics such as object-oriented programming, Java Development Kit components, and various Java concepts including methods, variables, and exceptions. Each lesson includes multiple choice, drag and drop, and fill-in-the-blank questions to assess understanding of Java programming principles. The document serves as a comprehensive resource for learners to test their knowledge and reinforce their understanding of Java programming concepts.

Uploaded by

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

Java SE Fundamentals Interactive Quiz Questions

Lesson 2

Q2.1 Answer. A, B, C are correct.

Q2.2 Multiple choice. Identify the items that relate to the benefits of object-oriented programming.
Choose all that apply.

• The source code of one object can be modified independently of the source code for another
object. (correct)

• By using methods, objects hide the details of their internal implementation. (correct)

• You can reuse an existing object in your code. (correct)

• A problematic object can be replaced by another object without affecting the rest of the
application. (correct)

• An object cannot be passed around within a system. (incorrect)

Q2.3 Drag and Drop. Identify the items that are included in the Java Development Kit (JDK) and drag
them into the box labeled JDK.

• Java Runtime Environment (correct)

• Compiler (correct)

• Java Virtual Machine (correct)

• Microprocessor (incorrect)

Q.2.4 Type the correct syntax for compiling Student.java.

Answer javac Student.java

Lesson 3

Q3.1 Based on what you see in the directory display, what is the name of the package name in which
Student .java resides?

Answer – test

Q3.2 True or False – Java is not case sensitive.

Answer – False
Q3.3 Multiple choice. Which of the following describes the main method? Choose all that apply.

A. Required for every Java program.

B. Requires { } for the method body.

C. A class that contains a main method is called a “main class”.

D. Is declared as: public static void main (String [] args)

Answer – all are true

Lesson 4

Q4.1 Drag and drop the term on the right to match the description on the left.

Can be declared and initialized variable

Combine two Strings concatenate

Evaluates to true or false boolean

Represents the kind of information or data held by type


a variable

The variable name identifier

Positive or negative whole number int

Positive or negative real numbers containing a double


decimal

Text data String

Q4.2 Order of precedence. Rank the mathematical operations by precedence using the dropdown on
the right of each answer to select the order.

• Operators within a pair of parentheses. (1)

• Increment and decrement operators (-- and ++). (2)

• Multiplication and division operators, evaluated from left to right. (3)

• Addition and subtraction operators, evaluated from left to right. (4)


Lesson 5

Q5.1 Multiple choice. Which of the following statements describes a boolean expression? Choose all
that apply.

A. Must evaluate to true or false.

B. Can contain relational operators.

C. Can assign a boolean directly.

D. Does not contain values.

Answers: A, B, and C

Q5.2 Drag and drop the code snippets into the white spaces in the code sample to complete the code
block.

Answers:
Lesson 6

Q6.1 What will print when you run the following code?

1 Shirt myShirt = new Shirt();


2 Shirt yourShirt = new Shirt();
3
4 myShirt = yourShirt;
5
6 myShirt.colorCode = 'R';
7 yourShirt.colorCode = 'G';
8
9 System.out.println("Shirt color: " + myShirt.colorCode);

a. R
b. Shirt color: R}
c. Shirt color: G
d. Shirt color: is colorCode
e. G

<answer: c >

Q6.2 Drag and drop the term on the right to match the description on the left.

Can be physical or conceptual, have properties, Object


and have behaviors
A blueprint for object instances Class

Color, size, name Properties

A term used when you create an instance of an Instantiate


object

Keyword used to create an object instance New

Q6.3 Which lines of code correctly instantiates a RainbowColor object and assigns it an object
reference? Choose all that apply.

a. RainbowColor red new RainbowColor();

b. RainbowColor yellow;

yellow = new RainbowColor();

c. RainbowColor blue = new RainbowColor();

d. RainbowColor green = RainbowColor();

<answers: b, c >

Q6.4 True/False

Stack and heap are two types of memory that Java uses.

<answer: True >

Lesson 7

Q7.1 Multiple choice. Why is it a best practice to not use the new keyword when creating a String
object? Choose one answer.

A. The new keyword is often overused in Java and using it could cause confusion.

B. Using the new keyword creates a duplicate object in memory and is not a memory efficient
coding practice.

C. Using the new keyword will cause a compiler error.

D. A String object cannot be created using the new keyword.

Answer: B

Q7.2 True or False. Java allows only a single return from a method.
Answer: True

Q7.3 The Java API documentation, a library specification for the Java language, provides what type of
information? Choose all that apply.

A. Lists and describes all of the classes in the Java API

B. Lists constructors, methods, and fields for a class

C. Demonstrates syntax for implementing a method

D. Lists parameters for methods

E. Includes some use cases for implementing a class

Answer: All are correct

Q7.4 Fill in the blank. You use the ______ keyword to make a variable a constant?

A. final

Q7.5 Drag and Drop. Use the drop-down on the right to select the term that matches the definition on the
left.

Explicitly changes the type of a variable to a type Type casting


that supports a smaller size value

Implicitly changes the type of a variable to a type promotion


that supports a larger size value

Objects, fields, and methods are stored here Heap memory

Local variables are stored here Stack memory

A primitive type used to store numbers with values float


to the right of the decimal point

Lesson 8

Q8.1 Fill in the blank. Use the ____ keyword with dot notation to access a field or method of the current
object.

Answer. this

Q8.2 Drag and Drop


A value passed into a method when it is invoked argument

A variable defined in a method declaration Method parameter

Determines a variable’s accessibility and how long scope


it persists

Its purpose is to instantiate an object of the class Constructor method


and return a reference to the object

It is called by another method to perform some Worker method


work.

It calls another method to perform some work Caller method

Combination of a method’s name, return value, Method signature


and the number, types, and order of
its parameters

Q8.3 Multiple choice. Which line of code in the FlannelShirt class is an example of the syntax for
accessing the colorCode static variable of the RedShirt class?

A. RedShirt.colorCode;

B. RedShirt.colorCode();

C. colorCode;

D. Static colorCode;

Answer A

Lesson 9

Q9.1 Drag and Drop

It uses access control to hide fields encapsulation

An access modifier that lets any class access or public


change the field’s value

A type of access control that lets only methods private


within the class have access

Used to initialize fields in an object constructor


Calling multiple constructors using the this Chaining constructors
keyword

Add arguments to a constructor overload

Q 9.2 fields of a class should be private, and those that need to be accessed should have public methods
for setting and getting their values. (fill in the blank)

Answer: public

Q9.3 What are the three arguments that you would set for this constructor?

public Shirt( ------------) {

setColorCode(colorCode);

setDescription(desc);

setPrice(price);

Answer: char colorCode, String desc, double price

Lesson 10

Q10.1 Which of the following statements about conditional operators is true? Choose all that apply.

a. A conditional operator can be used in conjunction with a relational operator.

b. You can use conditional operators to evaluate complex conditions as a whole.

c. &&, ||, ?:, and ! are conditional operators.

d. Conditional operators represent the conditions AND, OR, NOT.

Answers: a, b, d are correct.

Q10.2 Which of the following statements about switch statements is true? Choose all that apply.

a. switch is a keyword that represents a switch statement.

b. The value of a switch statement expression can be only of type char, byte, short, int, or String.

c. The case keyword indicates a value that you are testing. In combination with a literal value, it is
referred to as a case label.

d. A switch statement does not require a break statement.


Answers: a, b, c, d are true.

Q10.3 Debuggers can be used to solve logic problems and runtime errors. True or false

Answer true.

Lesson 11

Q11.1 Hot Spot selection. Duke is planning his month, and he needs to add an item to his schedule. Drag
the item into the cell of his calendar based on the code example.

String[][] schedule = new String[5][4];

schedule[3][2] = "Group Lunch"

Q11.2 Drag and Drop.

Use to iterate through a block of statements one Do/while


or more times.

Used to iterate through a block of statements and while


to perform the statements zero or more times.

Used to step through statements a set number of for


times

Is similar to a spreadsheet Two-dimensional array


A keyword that causes a loop to exit break

A keyword that causes the loop to skip the current continue


iteration and go to the next

Used to sort or manipulate large amounts of data Nested loop

Q 11.3 Which of the following statements describes an ArrayList? Choose all that apply.

A. It is part of the java.util package

B. It can store objects and primitives

C. It has a set of methods for managing its elements

D. It is one of several List classes

Answer: A, C, D

Lesson 12

Q12.1 In the following code sample, which keyword is missing from Line 01 that can be used to
implement an inheritance from the Clothing class.

Answer: extends

Q12.2. In terms of inheritance, ____ is a keyword that you use to invoke a method of a superclass.
Answer: super

Q12.3 Which of the following statements about an Abstract class are true? Choose all that apply.

a. An abstract class can be instantiated

b. Contains abstract methods that must be implemented by the subclass

c. Can contain concrete methods

d. Uses the abstract keyword

Answers: b, c, d are correct

Lesson 13

Q13.1 Drag and drop the description on the right to match the term on the left.

polymorphism The same method is implemented differently by


different classes.

instanceof An operator used to ensure that there is no casting


error

casting Creating a reference to a more specific type in


order to access a method

toString A method that gives very basic information about


the object

interface A type that can be implemented by any class and


can then be used as a reference type for that
object

Object class All classes have this at the very top of their
hierarchy

Q13.2 In the following code examples, type the method that has to be implemented in Line 07 in order
to prevent a compiler error.
Answer: doReturn()

Q13.3 All objects have which method?

a. toString()

b. toDo()

c. doReturn()

d. getString()

answer a. toString()

Lesson 14

Q14.1 Using the dropdown next to each item, match the exception with the cause of the exception.

java.lang.ArrayIndexOutOfBoundsException Attempt to access a non-existent array index

java.lang.ClassCastException Attempt to cast on object to an illegal type

java.lang.NullPointerException Attempt to use an object reference that has


not been instantiated

java.lang.OutOfMemoryError Exceptional conditions that are external to the


application and that the application usually
cannot anticipate or recover from

Q14.2 Match the type of exception that corresponds to the explanation of what caused the exception.
A Exception c:\notWriteableDir is a directory, but it is not
writeable.

B IllegalArgumentException The first argument passed to createTempFile should


be three or more characters long.

C Trying to access a nonexistent index of an array


java.lang.ArrayIndexOutOfBoundsException creates an exception.

< distracter answer> Null cannot be passed as an argument to a method.

14.3 Match the definition on the right to the term on the left.

Error Typically an unrecoverable external error

Unchecked

RuntimeException Typically caused by a programming mistake

Unchecked

Exception Recoverable error

Checked (Must be caught or thrown)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy