• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

Mock Exams – NavigableSet

4) What will be the output of the following program?

 package navset; import java.util.TreeSet; public class Ques02 { public static void main(String[] args) { MyNavigableSet objects = new MyNavigableSet(); objects.add(new Object()); System.out.println(objects); } } class MyNavigableSet extends TreeSet<String>{ public boolean add(Object value){ return super.add(value); } } 
  1. The program will compile and run fine to print the contents of the set.
  2. The program will raise a run-time exception telling that it is not possible to add objects of type ‘java.lang.Object’ in place of ‘java.lang.String’.
  3. The program will raise a compile-time error.

Answer

4) c.

A compile-time error telling that a name-clash has happened for the overridden method taking Object as argument.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact