What method would you use to add an element to an ArrayList?

Java Concepts Assessment For J.A

Quiz
•
Information Technology (IT)
•
University
•
Hard
sauarbh chopade
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
Use the 'insert' method.
Use the 'append' method.
Use the 'add' method.
Use the 'push' method.
2.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
Provide an example of method overloading in Java.
class Calculator { double add(int a, double b) { return a + b; } }
Example of method overloading: class Calculator { int add(int a, int b) { return a + b; } double add(double a, double b) { return a + b; } int add(int a, int b, int c) { return a + b + c; } }
class Calculator { void add(int a, int b) { return; } }
class Calculator { int add(int a) { return a; } }
3.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
Explain the concept of method overriding in inheritance.
Method overriding is when a superclass changes the implementation of a method in its subclass.
Method overriding prevents subclasses from using methods defined in their superclasses.
Method overriding is a way to create new methods in a subclass without affecting the superclass.
Method overriding allows a subclass to provide a specific implementation of a method already defined in its superclass, enabling customized behavior.
4.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
What is the purpose of a try-catch block in exception handling?
The purpose of a try-catch block is to handle exceptions and prevent program crashes.
To optimize the performance of the code.
To define global variables for the program.
To improve code readability and maintainability.
5.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
Write a for loop that prints numbers from 1 to 10.
for (i = 1; i < 10; i++) { console.log(i); }
for (let i = 1; i <= 10; i++) { console.log(i); }
for (let i = 1; i <= 5; i++) { console.log(i); }
for (let i = 0; i < 10; i++) { console.log(i + 1); }
6.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
What is inheritance in Java? Give an example.
For example, if we have a superclass 'Animal' with a method 'makeSound()', a subclass 'Dog' can inherit this method and provide its own implementation.
Inheritance is a way to create multiple instances of a class.
Inheritance allows a subclass to override methods from its superclass.
Inheritance is used to define interfaces in Java.
7.
MULTIPLE CHOICE QUESTION
15 mins • 1 pt
What is the difference between pre-increment and post-increment operators?
Pre-increment modifies the variable before use; post-increment modifies it after use.
Pre-increment and post-increment are the same.
Pre-increment is used only in loops.
Post-increment can only be used with integers.
Create a free account and access millions of resources
Similar Resources on Wayground
12 questions
Konteynerlar (C++)

Quiz
•
University
15 questions
DSA (QUIZ 7) -Greedy Algorithms and Complexity Analysis

Quiz
•
University
12 questions
Data Struct - S1_Array & Pointer

Quiz
•
University
20 questions
Pretest Alpro Dasar

Quiz
•
University
15 questions
DSA (Quiz 1) Arrays and Linked Lists

Quiz
•
University
16 questions
Java Basics Quiz for CH/PT Students

Quiz
•
University
11 questions
Структурированный тип данных массив

Quiz
•
10th Grade - University
10 questions
C-Volution (Hard)

Quiz
•
University
Popular Resources on Wayground
25 questions
Equations of Circles

Quiz
•
10th - 11th Grade
30 questions
Week 5 Memory Builder 1 (Multiplication and Division Facts)

Quiz
•
9th Grade
33 questions
Unit 3 Summative - Summer School: Immune System

Quiz
•
10th Grade
10 questions
Writing and Identifying Ratios Practice

Quiz
•
5th - 6th Grade
36 questions
Prime and Composite Numbers

Quiz
•
5th Grade
14 questions
Exterior and Interior angles of Polygons

Quiz
•
8th Grade
37 questions
Camp Re-cap Week 1 (no regression)

Quiz
•
9th - 12th Grade
46 questions
Biology Semester 1 Review

Quiz
•
10th Grade