InfyTQ Abstract, final and Interfaces Quiz 3

Question 1

Time: 00:00:00
What will be the output of the following code?

class Example

{

public static void main(String [] args)

{

    final int num;

   num = 1234;

    System.out.print(num);

  }

}

 

Compiler

Compiler

1234

1234

zero

zero

Run-time-error

Run-time-error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
What will be the output of the following program?

 

class Alphabet

{

public static void main(String [] args)

{

    final char A=’b’;

   A = ‘c’;

    System.out.print(A);

  }

}

Compile error

Compile error

Segmentation error

Segmentation error

c

c

Runtime error

Runtime error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
Which of the following lines in the interface below, will produce a compilation error?

 

interface Example

{

public static int a = 49;  //Line A

int b = 12;  //Line B

public static final int c = 345;  //Line C

}

 

C

C

A

A

B

B

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What will be the output of the following program?

 

abstract class Example

{

private int x,y;

public void prod (int a, int b)

{

x=a;

y=b;

System.out.println(x*y);

}

}

 

public class Main

{

public static void main (String [] args)

{

Example obj = new Example();

obj.prod(4,5);

}

}

 

Run time

Run time

Compile time

Compile time

20

20

zero

zero

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What will be the output of the following Java program?

interface test

{

int a = 45;

}

 

public class Main

{

public static void main(String [] args)

{

test.a = 46;

System.out.println(test.a);

}

}

45

45

46

46

Segmentation fault

Segmentation fault

Compiler Error

Compiler Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Consider the following two statements:

  1. We can create objects of abstract classes.

  2. We can create objects of interfaces.


Which of the following statements are true?

Statement 1

Statement 1

Statement 2

Statement 2

Both 1 and 2 are true

Both 1 and 2 are true

Both 1 and 2 are false

Both 1 and 2 are false

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
What do you mean by a blank final variable?

A final variable initialized with value “NULL”

A final variable initialized with value “NULL”

A final variable initialized with value “0”.

A final variable initialized with value “0”.

A final variable that is not initialized during declaration.

A final variable that is not initialized during declaration.

none of these

none of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
We can declare the main() method as final.

True

True

False

False

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
Consider the following two statements:

  1. Abstract classes can have child classes and abstract methods should be overridden.

  2. Final classes can have child classes and final methods can be overridden.


Which of the following statements is true?

Statement 1 is false, 2 is true

Statement 1 is false, 2 is true

Statement 1 is true, 2 is false

Statement 1 is true, 2 is false

Statement 1 is true, 2 is true

Statement 1 is true, 2 is true

Statement 1 is false, 2 is false

Statement 1 is false, 2 is false

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
Consider the following two statements:

  1. Final variables can’t be modified after initialization.

  2. Static variables can be modified after initialization.


Which of the following statements is true?

Statement 1 is false, 2 is true

Statement 1 is false, 2 is true

Statement 1 is true, 2 is false

Statement 1 is true, 2 is false

Statement 1 is true, 2 is true

Statement 1 is true, 2 is true

Statement 1 is false, 2 is false

Statement 1 is false, 2 is false

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/0

Accuracy

0%