Quiz 5

Quiz 5

University

10 Qs

quiz-placeholder

Similar activities

FGCT4025 Topic 3 - Method

FGCT4025 Topic 3 - Method

University

15 Qs

Passaggio parametri

Passaggio parametri

University

9 Qs

Topic 8-2: Method

Topic 8-2: Method

University

9 Qs

Quiz on Java Operators

Quiz on Java Operators

University

7 Qs

javaquizvivek

javaquizvivek

University

12 Qs

Java Control Flow statements

Java Control Flow statements

University

10 Qs

Java Arrays

Java Arrays

University

10 Qs

JAVA FINAL QUIZ FOR ASSESSMENT

JAVA FINAL QUIZ FOR ASSESSMENT

University

15 Qs

Quiz 5

Quiz 5

Assessment

Quiz

Computers

University

Hard

Created by

Ms. Asst.Prof

Used 1+ times

FREE Resource

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

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?