Menu
Question Index
...

Which line is required at LINE A for successful running of the following program?

public class GenericTypeSafetyDemo {
    public static void main(String args[])
    {
        NonGeneric obj1 = new NonGeneric(88);
        int value = obj1.getOb(); // LINE A
        System.out.println(value);
    }
}
class NonGeneric
{
    Object ob;
    NonGeneric(Object ob)
    {
        this.ob = ob;
    }
    Object getOb()
    {
        return ob;
    }
}


int value = (int)obj1.getOb();
int value = (Integer)obj1.getOb();
int value = (Object)obj1.getOb();
None of these

Doubts

Problems

Topic: How Generics Improve Type Safety In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App