Search Header Logo

Quiz 5

Authored by Ms. Asst.Prof

Computers

University

Used 1+ times

Quiz 5
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?

public class Tester {

 

        public static void main(String[] args) {

               Tester tester = new Tester();

               tester.evaluate(4, 2.5f);

        }

 

        public void evaluate(int a, int b) {

               System.out.print("First evaluate method invoked");

               System.out.println(a + b);

        }

 

        public void evaluate(float a, float b) {

               System.out.print("Second evaluate method invoked");

               System.out.println(a + b);

        }

}

First evaluate method invoked 6

Second evaluate method invoked 6.5

Compilation error as two methods with same name cannot exist in the same class

First evaluate method invoked 6.5

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

public class Tester {

        public static void main(String[] args) {

               Tester tester = new Tester();

               tester.evaluate(4.5, 2.5);

        }

 

        public void evaluate(int a, int b) {

               System.out.print("First evaluate method invoked");

               System.out.println(a + b);

        }

 

        public void evaluate(float a, float b) {

               System.out.print("Second evaluate method invoked");

               System.out.println(a + b);

        }

}

Second evaluate method invoked 7.0

Compilation error : The method evaluate(int, int) in the type Tester is not applicable for the arguments (double, double)

Second evaluate method invoked 6.0

First evaluate method invoked 6

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following are overloaded methods?

a. public void add(int a, int b) { }

    public void add(float a, float b, float c) { }

b. public int add(int a, int b, int c) { }

    public float add(int a, int b, int c) { }

c. public float add(float a, int b) { }

    public float add(int a, float b) { }

Only a

Only a and c

All a, b and c

Only a and b

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which among the following best describes encapsulation?

one It is a way of combining various data members into a single unit

It is a way of combining various member functions into a single unit

It is a way of combining various data members and member functions into a single unit which can operate on any data

It is a way of combining various data members and member functions that operate on those data members into a single unit

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Encapsulation is also called as?

Data Hidding

Data Hiding

Data Encapsulation

None of the above

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Encapsulation is implemented by using__________

public

private

defalut

protected

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If data members are private, what can we do to access them from the class object?

Create public member functions to access those data members

Create private member functions to access those data members

Create protected member functions to access those data members

Private data members can never be accessed from outside the class

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?