Menu
Question Index
...

What is the output of the following program?

class MyClassA<U> {
    U _;
    public MyClassA(U str) { _ = str; }
    public U get_() { return _; }
}
class MyClassB<T, V> extends MyClassA<V> { // LINE A
    public MyClassB(V v) { super(v);  }
    public String myMethod() {
        V input = get_();
        String inputString = input.toString();
        String result = "";
        for (int i = inputString.toCharArray().length; i > 0; i--) {
            int ch = inputString.toLowerCase().toCharArray()[i - 1];
            int newNumber = 0;
            while (ch > 0) {
                newNumber = newNumber * 10 + ch % 10;
                ch = ch / 10;
            }
            result += ((char) ((newNumber / 65) + 66));
        }
        return result;
    }
}
public class Manmohan {
    public static void main(String[] args) {
        MyClassB<Integer, StringBuilder> obj = new MyClassB<Integer, StringBuilder>(new StringBuilder("MERIT"));
        System.out.println(obj.myMethod());
    }
}


7371706577
KIHCO
JHGBN
Compilation Error at LINE A
Compilation Error at some other place
Runtime Error

Doubts

Problems

Topic: Java Generics

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App