Menu
Topics Index
...
`

Final keyword928


If you need explanation Read this topic

If you need Answer Take test on this topic

Final keyword928
What will be the output of the following program?
public class Final
{
    int printA = 20;

    public static void main(String[] args)
    {
        PrintB c = new PrintB();

        System.out.println("printA = " + c.printA);
        System.out.println("printB = " + c.printB);
    }
}

final class PrintA
{
    int printA = 5;
}

final class PrintB extends PrintA
{
    int printA = 10;
    int printB = 5;
}

A. printA = 5
printB = 5
B. printA = 10
printB = 5
C. printA = 20
printB = 5
D. Compilation Error
E. Runtime Error
Topic: final Keyword In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Answer d.
compilr err
class printA n printB r declrd with final keyword.
thes classes cant be overridden,cant inherit.
final nt allwd inheritance

Posted by NagaRaj Nataraj    2014-07-09 08:58:41


d

Posted by Harsh Singh    2014-07-09 09:04:09


ans d.
class declared with final ,these class can't extend

Posted by Maheshwari Natarajan    2014-07-09 09:05:00


Ans D; Class declared with final keyword can't be inherited

Posted by BalRam At    2014-07-09 09:45:32


yaya d,b/c final keyword

Posted by Abbii Tilku    2014-07-09 10:28:08


d

Posted by Mohsin Deshmukh    2014-07-09 11:15:48


d

Posted by Rishav Seksaria    2014-07-10 03:26:36


Congratulations NagaRaj Nataraj. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-10 04:29:02


D

Posted by Bhuvaneswari Bhuvana    2014-07-10 13:36:27


© meritcampus 2019

All Rights Reserved.

Open In App