Java Objects - Medium Practice Quiz
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Medium
VIKAS BANDARU
Used 1+ times
FREE Resource
Enhance your content in a minute
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which statement best describes a parameterised constructor in OOP?
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?
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?
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?
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?
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?
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?
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

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
20 questions
Latihan Soal Administrasi Infrastruktur Jaringan XII TKJ
Quiz
•
10th - 12th Grade
20 questions
Pemrograman Dasar 3
Quiz
•
9th - 12th Grade
20 questions
PTS KELAS 9
Quiz
•
9th - 12th Grade
17 questions
Đề ôn tập cuối HKI lớp 5
Quiz
•
6th Grade - University
20 questions
TEST1.PY
Quiz
•
10th Grade - University
16 questions
Properties of shapes and materials (IED)
Quiz
•
9th - 12th Grade
15 questions
Internet Safety Quiz
Quiz
•
9th - 12th Grade
20 questions
Data structure test1
Quiz
•
12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
