Java Objects - Medium Practice Quiz

Java Objects - Medium Practice Quiz

12th Grade

20 Qs

quiz-placeholder

Similar activities

Conditionals

Conditionals

9th - 12th Grade

18 Qs

K12 Bài 13: Bảo mật thông tin trong các HCSDL

K12 Bài 13: Bảo mật thông tin trong các HCSDL

12th Grade

20 Qs

Tin học 11 chương I

Tin học 11 chương I

1st - 12th Grade

20 Qs

Computer Security Measure

Computer Security Measure

11th Grade - University

19 Qs

Preguntas sobre Excel 2016

Preguntas sobre Excel 2016

6th Grade - University

15 Qs

Excel - Funciones de Estadística

Excel - Funciones de Estadística

10th - 12th Grade

20 Qs

Problem Solving : Design Solution

Problem Solving : Design Solution

12th Grade

15 Qs

Pretest หน่วยที่ 4

Pretest หน่วยที่ 4

KG - University

15 Qs

Java Objects - Medium Practice Quiz

Java Objects - Medium Practice Quiz

Assessment

Quiz

Computers

12th Grade

Practice Problem

Medium

Created by

VIKAS BANDARU

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which statement best describes a parameterised constructor in OOP?

A method that returns a value to the caller
A special method that sets initial field values using arguments during object creation
A static initializer that runs once per class
Any method that accepts parameters
A method that only draws on screen

Answer explanation

A parameterised constructor takes arguments and assigns initial values to fields when an object is created.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given: String s = "0123456789"; System.out.println(s.substring(4)); What is printed?

456789
123
3456789
56789
1234

Answer explanation

substring(4) returns characters from index 4 to end, yielding 456789.

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Given: String s = "0123456789"; System.out.println(s.substring(s.lastIndexOf('3'), s.indexOf('8'))); What is printed?

345678
34567
45678
34
567

Answer explanation

lastIndexOf('3') is 3, indexOf('8') is 8; substring(3,8) gives 34567.

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Given:

String s = "abcabc";

System.out.println(s.lastIndexOf("abc", 2));

System.out.println(s.substring(3, 3).length());

What is printed on two lines?

3 and 0
0 and 0
0 and 3
-1 and 0
3 and 3

Answer explanation

lastIndexOf("abc", 2) searches up to index 2 inclusive, finds abc at 0; substring(3,3) is empty, length is 0.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which option correctly identifies a parameterised method that also returns a value?

void makeVisible()
int moveHorizontal()
int moveHorizontal(int distance)
void changeColor(String color)
void moveDown()

Answer explanation

moveHorizontal(int distance) both takes a parameter and could be defined to return an int; among given options, it matches signature of parameterised and returning method.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider class Account { int balance; Account(int initial){ balance = initial + 50; } } After Account a = new Account(150); what is a.balance?

0
150
50
200
100

Answer explanation

The parameterised constructor sets balance = initial + 50, so 150 + 50 = 200.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In Circle, which method changes position based on caller-provided information?

moveRight()
moveDown()
moveHorizontal(int distance)
makeVisible()
draw()

Answer explanation

moveHorizontal changes xPosition using the distance provided by the caller.

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?