Menu
Question Index
...

What will be the output of the following program?

public class GenericsMethodDemo {
    public static void main(String args[]) {
        String str = "Merit Campus";
        printString(10);
        printString(str);
    }
    public static <E> void printString(Integer str) {
        System.out.println("Inreger = " + str);
    }
    public static <E> void printString(E str) {
        System.out.println("String = " + str);
    }
}


Inreger = 10
String = Merit Campus
String = 10
Inreger = Merit Campus
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Generics In Methods And Constructors

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App