MCQs > IT & Programming > Java MCQs > Introduction to Java MCQs

Introduction to Java MCQ

Assigning ____ to a field means that no other classes can access the fields values.

Answer

Correct Answer: Private access

Note: This Question is unanswered, help us to find answer for this one

A method can receive ____ arguments, even if it is defined as needing double arguments.

Answer

Correct Answer: Integer

Note: This Question is unanswered, help us to find answer for this one

A ________ is a value that signals when the end of a list of values has been reached.

Answer

Correct Answer: Sentinel

Note: This Question is unanswered, help us to find answer for this one

When method printf requires multiple arguments, the arguments are separated with ________.

Answer

Correct Answer: Commas (,)

Note: This Question is unanswered, help us to find answer for this one

When you instantiate an object from a class, ____ is reserved for each instance field in the class.

Answer

Correct Answer: Memory

Note: This Question is unanswered, help us to find answer for this one

The signature of a method consists of ________.

Answer

Correct Answer: Method name and parameter list

Note: This Question is unanswered, help us to find answer for this one

The __________ function returns the smallest integer that is greater than or equal to the number.

Answer

Correct Answer: CEILING

Note: This Question is unanswered, help us to find answer for this one

The ________ properties are defined in the javafx.scene.text.text class.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

The ________ method is used to display a message dialog.

Answer

Correct Answer: ShowMessageDialog

Note: This Question is unanswered, help us to find answer for this one

The ________ loads java bytecode to the memory.

Answer

Correct Answer: Class loader

Note: This Question is unanswered, help us to find answer for this one

The ____ method takes a string argument and returns its double value.

Answer

Correct Answer: ParseDouble()

Note: This Question is unanswered, help us to find answer for this one

The ____ method converts any object to a string.

Answer

Correct Answer: ToString()

Note: This Question is unanswered, help us to find answer for this one

The ____ class represents more serious errors from which your program usually cannot recover.

Answer

Correct Answer: Error

Note: This Question is unanswered, help us to find answer for this one

The ____ class provides the definitions for gui objects.

Answer

Correct Answer: Control

Note: This Question is unanswered, help us to find answer for this one

When you create an array of objects, each reference is assigned the value ____.

Answer

Correct Answer: Null

Note: This Question is unanswered, help us to find answer for this one

The expression ""Java "" + 1 + 2 + 3 evaluates to ________.

Answer

Correct Answer: Java 123

Note: This Question is unanswered, help us to find answer for this one

The cookie property is created with a required ____ attribute.

Answer

Correct Answer: Name

Note: This Question is unanswered, help us to find answer for this one

The class used as a basis for inheritance is the ____ class.

Answer

Correct Answer: Base

Note: This Question is unanswered, help us to find answer for this one

The characters ____ move the cursor to the next line when used within a println() statement.

Answer

Correct Answer: \n

Note: This Question is unanswered, help us to find answer for this one

The character class ____ from java.lang.object.

Answer

Correct Answer: Inherits

Note: This Question is unanswered, help us to find answer for this one

Static methods can only operate on ________ fields.

Answer

Correct Answer: Static

Note: This Question is unanswered, help us to find answer for this one

You use the keyword ________ to reference a method in the superclass from a subclass.

Answer

Correct Answer: Super

Note: This Question is unanswered, help us to find answer for this one

You compare two strings s1 and s2 using ________.

Answer

Correct Answer: S1.compareTo(s2

Note: This Question is unanswered, help us to find answer for this one

You can use the ________ method to replace an item at a specific location in an arraylist.

Answer

Correct Answer: Set

Note: This Question is unanswered, help us to find answer for this one

You can obtain the server's hostname by invoking ________ on an applet.

Answer

Correct Answer: GetCodeBase().getHost()

Note: This Question is unanswered, help us to find answer for this one

You can leave out the ____ statements in a switch structure.

Answer

Correct Answer: Break

Note: This Question is unanswered, help us to find answer for this one

You can declare two variables with the same name in __________.

Answer

Correct Answer: Different methods in a class

Note: This Question is unanswered, help us to find answer for this one

You can create an arraylist using ________.

Answer

Correct Answer: New ArrayList<>()

Note: This Question is unanswered, help us to find answer for this one

Whenever a method requires multiple arguments, the arguments are always separated with ____.

Answer

Correct Answer: Commas

Note: This Question is unanswered, help us to find answer for this one

Use the ________ method to write text to a web page.

Answer

Correct Answer: Document.new

Note: This Question is unanswered, help us to find answer for this one

To use a public variable or method outside of its class, you must ____ the name.

Answer

Correct Answer: Qualify.

Note: This Question is unanswered, help us to find answer for this one

To specify a stacking order, one can use the _____ property.

Answer

Correct Answer: Z-index

Note: This Question is unanswered, help us to find answer for this one

The __________ method parses a string s to an int value.

Answer

Correct Answer: Integer.parseInt(s);

Note: This Question is unanswered, help us to find answer for this one

The __________ method immediately terminates the program.

Answer

Correct Answer: System.exit(0);

Note: This Question is unanswered, help us to find answer for this one

The not equal comparison operator in java is ________.

Answer

Correct Answer: !=

Note: This Question is unanswered, help us to find answer for this one

To convert a javascript object to a json string, you use the ____ method.

Answer

Correct Answer: Stringify

Note: This Question is unanswered, help us to find answer for this one

When an object of one class is a data field within another class, they are related by ____.

Answer

Correct Answer: Composition

Note: This Question is unanswered, help us to find answer for this one

Some programmers refer to a catch block as a ____ clause.

Answer

Correct Answer: Clause

Note: This Question is unanswered, help us to find answer for this one

Regarding enumerations, the ____ method returns the name of the calling constant object.

Answer

Correct Answer: ToString

Note: This Question is unanswered, help us to find answer for this one

Programs that are embedded in a web page are called java ____.

Answer

Correct Answer: Applets

Note: This Question is unanswered, help us to find answer for this one

Overloaded methods always have the same _________.

Answer

Correct Answer: Method name

Note: This Question is unanswered, help us to find answer for this one

One or more objects may be created from a(n)________.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

On many keyboards, the break key is also the ____ key.

Answer

Correct Answer: Pause

Note: This Question is unanswered, help us to find answer for this one

Methods that set values are called ____ methods.

Answer

Correct Answer: Mutator

Note: This Question is unanswered, help us to find answer for this one

Method calls cannot be distinguished by ________.

Answer

Correct Answer: Return type

Note: This Question is unanswered, help us to find answer for this one

Local variables must be ________.

Answer

Correct Answer: Initialized before their values are used in expression

Note: This Question is unanswered, help us to find answer for this one

Javascript requires _____ programming knowledge and experience as java.

Answer

Correct Answer: The same

Note: This Question is unanswered, help us to find answer for this one

Java.util.vector is a subtype of ________.

Answer

Correct Answer: Java.util.AbstractList
Java.util.List

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

Java, c#, and vb.net are examples of ________.

Answer

Correct Answer: Object-oriented languages

Note: This Question is unanswered, help us to find answer for this one

Java uses class ________ to represent colors using their rgb values.

Answer

Correct Answer: Color

Note: This Question is unanswered, help us to find answer for this one

Java contains a class named ____ that allows you to produce dialog boxes.

Answer

Correct Answer: JOptionPane

Note: This Question is unanswered, help us to find answer for this one

Java ________ can run from a web browser.

Answer

Correct Answer: Applets

Note: This Question is unanswered, help us to find answer for this one

It is important that the loop control ____ be altered within the body of the loop.

Answer

Correct Answer: Variable

Note: This Question is unanswered, help us to find answer for this one

Invoking ________ returns the number of the elements in an arraylist x.

Answer

Correct Answer: X.size

Note: This Question is unanswered, help us to find answer for this one

Information is passed to a method in ________.

Answer

Correct Answer: The arguments to the method

Note: This Question is unanswered, help us to find answer for this one

In pcdata, the ____ symbol is used to indicate a special character.

Answer

Correct Answer: $

Note: This Question is unanswered, help us to find answer for this one

In order to allocate the needed memory for an object, you must use the ____ operator.

Answer

Correct Answer: New

Note: This Question is unanswered, help us to find answer for this one

In java, you use variables of type ____ to store integers, or whole numbers.

Answer

Correct Answer: Int

Note: This Question is unanswered, help us to find answer for this one

In java, ________ must be declared before they can be used.

Answer

Correct Answer: Variables

Note: This Question is unanswered, help us to find answer for this one

In java, the word true is ________.

Answer

Correct Answer: A Boolean literal

Note: This Question is unanswered, help us to find answer for this one

In java graphics, coordinate units are measured in ________.

Answer

Correct Answer: Pixels.

Note: This Question is unanswered, help us to find answer for this one

In java all output uses the ______ data type.

Answer

Correct Answer: String

Note: This Question is unanswered, help us to find answer for this one

In a do…while loop, the loop will continue to execute until ____.

Answer

Correct Answer: The loop control variable is false

Note: This Question is unanswered, help us to find answer for this one

If you attempt to add an int, a byte, a long, and a float, the result will be a ________ value.

Answer

Correct Answer: Float

Note: This Question is unanswered, help us to find answer for this one

If an exception occurs in a try-catch block, the code in the finally clause ________.

Answer

Correct Answer: Is executed

Note: This Question is unanswered, help us to find answer for this one

If a programming language does not support ____, the language is not considered object-oriented.

Answer

Correct Answer: Polymorphism

Note: This Question is unanswered, help us to find answer for this one

If a key is not in the list, the binarysearch method returns ________.

Answer

Correct Answer: -(insertion point + 1

Note: This Question is unanswered, help us to find answer for this one

For input we will use the ______ class.

Answer

Correct Answer: Scanner

Note: This Question is unanswered, help us to find answer for this one

Exception handling helps you create ________ programs.

Answer

Correct Answer: Fault-tolerant

Note: This Question is unanswered, help us to find answer for this one

Every object is a _____ of a more general class.

Answer

Correct Answer: Member

Note: This Question is unanswered, help us to find answer for this one

Every class in java, except ________, extends an existing class.

Answer

Correct Answer: Object

Note: This Question is unanswered, help us to find answer for this one

Declaring instance variables ________ is known as data hiding or information hiding.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

Data items you use in a call to a method are called ____.

Answer

Correct Answer: Arguments

Note: This Question is unanswered, help us to find answer for this one

Character literals are enclosed in ________; string literals are enclosed in ________.

Answer

Correct Answer: Single quotes; double quotes

Note: This Question is unanswered, help us to find answer for this one

By convention, a class diagram contains the ____ following each attribute or method.

Answer

Correct Answer: Data type

Note: This Question is unanswered, help us to find answer for this one

Boolean values can be displayed as the words true and false with the ________ format specifier.

Answer

Correct Answer: %b

Note: This Question is unanswered, help us to find answer for this one

Before entering a loop, the first input statement, or ____, is retrieved.

Answer

Correct Answer: Priming read

Note: This Question is unanswered, help us to find answer for this one

Arguments to methods always appear within ________.

Answer

Correct Answer: Parentheses

Note: This Question is unanswered, help us to find answer for this one

Any field declared with keyword ________ is constant.

Answer

Correct Answer: Final

Note: This Question is unanswered, help us to find answer for this one

Another name for a nonstatic member class is a(n) ____.

Answer

Correct Answer: Inner class

Note: This Question is unanswered, help us to find answer for this one

A static method can ________.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

A method must declare to throw ________.

Answer

Correct Answer: Unchecked exceptions

Note: This Question is unanswered, help us to find answer for this one

A method that has no implementation is called a/an ____ method.

Answer

Correct Answer: Abstract

Note: This Question is unanswered, help us to find answer for this one

A method header is also called a(n) _____.

Answer

Correct Answer: Declaration

Note: This Question is unanswered, help us to find answer for this one

A loop controlled by the user is a type of ____ loop.

Answer

Correct Answer: Indefinite

Note: This Question is unanswered, help us to find answer for this one

A literal string is a(n) ____ object.

Answer

Correct Answer: Anonymous

Note: This Question is unanswered, help us to find answer for this one

A javafx action event handler is an instance of ________.

Answer

Correct Answer: EventHandler

Note: This Question is unanswered, help us to find answer for this one

A javafx action event handler contains a method ________.

Answer

Correct Answer: Public void handle(ActionEvent e)

Note: This Question is unanswered, help us to find answer for this one

A java program is stored in an executable file called a(n) ____ file.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

A java character is stored in ________.

Answer

Correct Answer: Two bytes

Note: This Question is unanswered, help us to find answer for this one

A class specifies the ________ and ________ that a particular type of object has.

Answer

Correct Answer: Fields; methods

Note: This Question is unanswered, help us to find answer for this one

A block is enclosed inside ________.

Answer

Correct Answer: Braces

Note: This Question is unanswered, help us to find answer for this one