Search Header Logo

Introduction to object oriented programming

Authored by scoremaster JAVA

Computers

10th Grade

Introduction to object oriented programming
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

47 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which OOP principle means 'hiding internal details and showing only essential features'?

Encapsulation

Polymorphism

Inheritance

Abstraction

Answer explanation

The correct answer is 'Abstraction'. It refers to the OOP principle of hiding complex implementation details and exposing only the necessary features, allowing users to interact with objects without needing to understand their inner workings.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In Java, which of the following is not a primitive data type?

byte

short

String

boolean

Answer explanation

In Java, primitive data types include byte, short, and boolean. However, String is not a primitive type; it is an object that represents a sequence of characters. Therefore, the correct answer is String.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method reads an entire line of text using Scanner?

next()

nextChar()

nextLine()

readLine()

Answer explanation

The correct method to read an entire line of text using Scanner is nextLine(). The next() method reads the next token, while nextChar() and readLine() are not valid methods in the Scanner class.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The expression 17/5 in Java evaluates to:

3.4

3

3.0

4

Answer explanation

In Java, when both operands are integers, integer division is performed. Thus, 17/5 evaluates to 3, discarding the decimal part. Therefore, the correct answer is 3.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which statement about the Math class is true?

You must create a Math object to use its methods

Most methods in Math are static

Math methods require java.util import

Math.round returns double only

Answer explanation

The correct statement is that most methods in the Math class are static, allowing them to be called without creating an instance of the class. The other options are incorrect regarding object creation, imports, and return types.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a switch statement, the 'default' case:

Must be the first case

Is optional

Must be last

Requires a break

Answer explanation

The 'default' case in a switch statement is optional, meaning it does not have to be included. It can appear anywhere, but it is not required to be the first or last case, nor does it necessarily require a break.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

System.out.print and System.out.println differ in that println:

Prints in bold

Flushes the buffer

Appends a newline

Prints to stderr

Answer explanation

System.out.println appends a newline after printing, while System.out.print does not. This means println moves the cursor to the next line, making it useful for formatting output.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?