Introduction to Java MCQs

Introduction to Java MCQs

Answer these 90+ Introduction to Java MCQs and assess your grip on the subject of Introduction to Java. Scroll below and get started!

1: A block is enclosed inside ________.

A.   Parentheses

B.   Braces

C.   Brackets

D.   Quotes

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

A.   Fields; object names

B.   Fields; methods

C.   Relationships; methods

3: A java character is stored in ________.

A.   One byte

B.   Two bytes

C.   Three bytes

D.   Four bytes

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

A.   Exe

B.   Class

C.   Java

D.   Js

5: A javafx action event handler contains a method ________.

A.   Public void actionPerformed(ActionEvent e)

B.   Public void actionPerformed(Event e)

C.   Public void handle(ActionEvent e)

D.   Public void handle(Event e

6: A javafx action event handler is an instance of ________.

A.   ActionEvent

B.   Action

C.   EventHandler

D.   EventHandler

7: A literal string is a(n) ____ object.

A.   Anonymous

B.   Inherits

C.   Length()

D.   Reference

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

A.   Indefinite

B.   Definite

C.   Counter-controlled

D.   Incrementing

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

A.   Parentheses

B.   Declaration

C.   Abstraction

D.   Accessor

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

A.   Abstract

B.   Overloaded

C.   Interface

D.   Implementation

11: A method must declare to throw ________.

A.   RuntimeException

B.   Error

C.   Checked exceptions

D.   Unchecked exceptions

12: A static method can ________.

A.   A static method can _______.call only other static methods of the same class directly

B.   Manipulate only static fields in the same class directly

C.   Be called using the class name and a dot (.)

D.   All of the above

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

A.   Comes into scope

B.   Integer

C.   Inner class

D.   Reference

14: Any field declared with keyword ________ is constant.

A.   Static

B.   Const

C.   Constant

D.   Final

15: Arguments to methods always appear within ________.

A.   Brackets

B.   Parentheses

C.   Curly braces

D.   Quotation marks

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

A.   Prefix increment

B.   Accumulating

C.   Incrementing

D.   Priming read

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

A.   %b

B.   %d

C.   %f

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

A.   Class

B.   Data type

C.   Argument

D.   Data field

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

A.   Single quotes; double quotes

B.   Standard output device

C.   Identifiers can contain spaces

D.   String concatenation operator

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

A.   Data fields

B.   Modifiers

C.   Accessors

D.   Arguments

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

A.   Secure

B.   Private

C.   Static

D.   Masked

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

A.   ImageIcon

B.   Object

C.   SetText

D.   Private

23: Every object is a _____ of a more general class.

A.   Member

B.   Accessor

C.   Mutator

D.   Method

24: Exception handling helps you create ________ programs.

A.   High-performance

B.   Logic-error-free

C.   Fault-tolerant

D.   Compilation-error-free

25: For input we will use the ______ class.

A.   Scanner

B.   Printer

C.   None of these

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

A.   Low is 4 and high is 6

B.   List1 is 2.5 3.1, 3.1, 6.4

C.   Java.util.Arrays.sort(scores)

D.   -(insertion point + 1

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

A.   Polymorphism

B.   Syntax

C.   Applets

D.   Loops

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

A.   ClassCastException

B.   Is executed

C.   Throwable

D.   Print

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

A.   Float

B.   Int

C.   Char

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

A.   The loop control variable is false

B.   ++score = score + 1

C.   Event-controlled

D.   Prefix increment operator

31: In java all output uses the ______ data type.

A.   Int

B.   Scan

C.   String

D.   Double

E.   Char

32: In java graphics, coordinate units are measured in ________.

A.   Dots.

B.   Pixels.

C.   Points.

D.   Inches

33: In java, the word true is ________.

A.   A Java keyword

B.   A Boolean literal

C.   Same as value 1

D.   Same as value 0

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

A.   Variables

B.   Literals

C.   Key words

D.   Comments

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

A.   Constant

B.   \n

C.   Input

D.   Int

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

A.   . nested

B.   Loop

C.   Get

D.   New

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

A.   *

B.   #

C.   $

38: Information is passed to a method in ________.

A.   The method name

B.   That method's return

C.   The method body

D.   The arguments to the method

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

A.   0.0, 0.5

B.   X.get(0)

C.   X.clear()

D.   X.size

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

A.   Infinite

B.   Variable

C.   Negative

D.   Validating data

41: Java ________ can run from a web browser.

A.   Applications

B.   Applets

C.   Servlets

D.   Micro Edition programs

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

A.   JOptionPane

B.   Vehicle.class

C.   Semicolon

D.   Encapsulation

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

A.   Class, block

B.   Color

C.   Math.sqrt(900);

D.   Classes

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

A.   Client operating systems

B.   Object-oriented languages

C.   Thin-client applications

D.   Structured queries

45: Java.util.vector is a subtype of ________.

A.   Java.util.ArrayList

B.   Java.util.LinkedList, java.util.List

C.   Java.util.AbstractList

D.   Java.util.Vector

E.   Java.util.List

46: Javascript requires _____ programming knowledge and experience as java.

A.   Backslash

B.   Case sensitive

C.   The same

D.   Slashes

47: Local variables must be ________.

A.   Initialized when they're declared

B.   Initialized before their values are used in expression

C.   Declared and initialized in two steps

D.   Declared at the top of the main method's body

48: Method calls cannot be distinguished by ________.

A.   Return type

B.   Class, block

C.   Method name

D.   The return type

49: Methods that set values are called ____ methods.

A.   Mutator

B.   Modifier

C.   Access

D.   Creator

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

A.   False

B.   Variable

C.   True

D.   Pause