Java Mastery Challenge

Java Mastery Challenge

University

10 Qs

quiz-placeholder

Similar activities

Text Features

Text Features

3rd Grade - University

10 Qs

JavaScript

JavaScript

University

15 Qs

bedwars quiz

bedwars quiz

University - Professional Development

10 Qs

OCA Chuong 2

OCA Chuong 2

University

11 Qs

Soal Ujian Semester Genap

Soal Ujian Semester Genap

7th Grade - University

15 Qs

Descriptive Text

Descriptive Text

12th Grade - University

10 Qs

Acronyms for all

Acronyms for all

University

11 Qs

Java Mastery Challenge

Java Mastery Challenge

Assessment

Quiz

English

University

Hard

Created by

Dhrudeep Vaghashiya

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main principle of object-oriented programming?

Inheritance of properties from a parent class.

Encapsulation of data and behavior into objects.

Static typing of all variables in the program.

Polymorphism through method overloading only.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the difference between an interface and an abstract class in Java.

An interface can have instance variables, while an abstract class cannot.

An abstract class can be instantiated, but an interface cannot.

An interface can extend multiple classes, while an abstract class can only extend one.

An interface defines a contract for classes to implement, while an abstract class can provide some method implementations and state.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the time complexity of accessing an element in an ArrayList?

O(log n)

O(n)

O(n^2)

O(1)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Describe the concept of inheritance in Java with an example.

class Vehicle { void start() { System.out.println('Vehicle started'); } } class Car extends Vehicle { void start() { System.out.println('Car is running'); } }

class Plant { void grow() { System.out.println('Plant growing'); } } class Tree extends Plant { void grow() { System.out.println('Tree is tall'); } }

class Animal { void makeSound() { System.out.println('Meow'); } } class Cat extends Animal { void makeSound() { System.out.println('Roar'); } }

Example: class Animal { void makeSound() { System.out.println('Animal sound'); } } class Dog extends Animal { void makeSound() { System.out.println('Bark'); } }

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the 'final' keyword in Java?

The 'final' keyword is used to create interfaces.

The 'final' keyword allows multiple inheritance in classes.

The 'final' keyword is used to define abstract classes.

The 'final' keyword is used to declare constants, prevent method overriding, and prevent inheritance.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you implement a stack using an array in Java?

Implement the stack using a HashMap.

Create a class with only a push method.

Use a linked list to implement the stack.

Create a class with an array, a top index, and methods for push, pop, and peek.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is polymorphism and how is it achieved in Java?

Polymorphism is achieved through the use of interfaces only.

Polymorphism is the ability to create multiple classes in Java.

Polymorphism allows objects to be created without any methods.

Polymorphism is the ability of an object to take on many forms, achieved in Java through method overriding and method overloading.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?