java 11-10-2023

java 11-10-2023

Professional Development

11 Qs

quiz-placeholder

Similar activities

Datatypes and Flowcontrol

Datatypes and Flowcontrol

Professional Development

15 Qs

Elearn, Emails, Netiquette

Elearn, Emails, Netiquette

Professional Development

10 Qs

Cyber 2 Module 4

Cyber 2 Module 4

9th Grade - Professional Development

15 Qs

Quality Day 22 Oct 2021

Quality Day 22 Oct 2021

Professional Development

10 Qs

JSKBS - Database Management System

JSKBS - Database Management System

Professional Development

15 Qs

CSS Quiz 2

CSS Quiz 2

University - Professional Development

10 Qs

Functions on C

Functions on C

Professional Development

15 Qs

Ice Breaker Challenge- Guess the Tool by Its Logo

Ice Breaker Challenge- Guess the Tool by Its Logo

Professional Development

10 Qs

java 11-10-2023

java 11-10-2023

Assessment

Quiz

Computers

Professional Development

Practice Problem

Hard

Created by

DEVAKI AMIR

Used 4+ times

FREE Resource

AI

Enhance your content in a minute

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

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

i) Fill in the blank space to make this code an example of Polymorphism

ii) predict whether it prints the base class or derived class

class BuggyBread1 {
public String method() {
return "Base Class - BuggyBread1";
}
}

class BuggyBread2 extends BuggyBread1{

private static int counter = 0;

public String _______(int x) {
return "Derived Class - BuggyBread2";
}
public static void main(String[] args) {
BuggyBread1 bg = new BuggyBread2();
System.out.println(bg.method());
}
}

i) method

ii) prints the base class

i)Buggybread2

ii)prints the base class

i) method

ii)prints the derived class

i)Buggybread2

ii)prints the derived class

2.

FILL IN THE BLANK QUESTION

1 min • 1 pt

Fill in the blanks to print the output "Kapil". Separate the answers with ','.

class Person {

      private String name;  

    public String getName() { return name; }

    public void setName(String newName)

    {

        this.name = newName;

    }

}

  

class Main {

    public static void main(String[] args)

    {

        Person person = new Person();

                person._______("kapil");

        System.out.println(person.______());

    }

}

3.

FILL IN THE BLANK QUESTION

2 mins • 1 pt

Predict the output of the following code.

import java.util.Random;  

class DeliveryBoy {  

    public void deliver() {

        System.out.println("Delivering Item");

    }  

    public static void main(String[] args) {

        DeliveryBoy deliveryBoy = getDeliveryBoy();

        deliveryBoy.deliver();

    }  

    private static DeliveryBoy getDeliveryBoy() {

        Random random = new Random();

        int number = random.nextInt(5);

        return number % 2 == 0 ? new Postman() : new FoodDeliveryBoy();

    }

}  

class Postman extends DeliveryBoy {

    @Override

    public void deliver() {

        System.out.println("Delivering Letters");

    }

}  

class FoodDeliveryBoy extends DeliveryBoy {

    @Override

    public void deliver() {

        System.out.println("Delivering Food");

    }

}

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What do we mean by the "state" of an object?

Its behavior

Its methods

Its interface

The values assigned to its instance variables

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Vehicle {
private static String manufacturingDate = "2016";
}
public class Car extends Vehicle{
public static void main(String args[]){
System.out.println(manufacturingDate);
}
}

2016

No Output

error - The field Vehicle.manufacturingDate is not visible

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Vehicle {
private static String manufacturingDate = "2016";
static public class Car extends Vehicle{
public static void main(String args[]){
System.out.println(manufacturingDate);
}
}
}

2016

No Output

error - The field Vehicle.manufacturingDate is not visible

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Static Polymorphic in Java is achieved through ..

Method Overloading

Method Overriding

Variable Overloading

Variable Overriding

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?