Menu
Question Index
...

What will be the output of the following program?

public class GenericsMethodDemo {
    public static <E> void printArray(E[] elements) {  
        for ( E element : elements){          
            System.out.print(element +" ");
        }  
    }  
  
    public static void main( String args[] ) {  
        Character[] charArray = { 'M', 'E', 'R', 'I', 'T','C','A','M','P','U', 'S'};  
        printArray( charArray );  
    }  
}


M E R I T C A M P U S
Some other output
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