zoukankan      html  css  js  c++  java
  • 【笔试题】Overloading in Java

    笔试题 Overloading in Java

    Question 1 以下程序的输出结果为( )。

    public class Test {
        public int getData() {
            return 0;
        }
    
        public long getData() {
            return 1;
        }
    
        public static void main(String[] args) {
            Test obj = new Test();
            System.out.println(obj.getData());
        }
    }
    

    a) 1
    b) 0
    c) Runtime error
    d) Compilation error

    参考答案

    ``` d ```

    Question 2 以下程序的输出结果为( )。

    public class Test {
        public int getData(String temp) throws IOException {
            return 0;
        }
    
        public int getData(String temp) throws Exception {
            return 1;
        }
    
        public static void main(String[] args) {
            Test obj = new Test();
            System.out.println(obj.getData("GFG"));
        }
    }
    

    a) 0
    b) 1
    c) Compilation error
    d) Runtime error

    参考答案

    ``` c ```

    Question 3 以下程序的输出结果为( )。

    public class Test {
        private String function() {
            return ("GFG");
        }
    
        public final static String function(int data) {
            return ("GeeksforGeeks");
        }
    
        public static void main(String[] args) {
            Test obj = new Test();
            System.out.println(obj.function());
        }
    }
    

    a) Compilation error
    b) Runtime error
    c) GFG
    d) None of these

    参考答案

    ``` c ```

    Question 4 以下程序的输出结果为( )。

    public class Test {
        private String function(String temp, int data) {
            return ("GFG");
        }
    
        private String function(int data, String temp) {
            return ("GeeksforGeeks");
        }
    
        public static void main(String[] args) {
            Test obj = new Test();
            System.out.println(obj.function(4, "GFG"));
        }
    }
    

    a) GFG
    b) GeeksforGeeks
    c) Compilation error
    d) Runtime error

    参考答案

    ``` b ```

    Question 5 以下程序的输出结果为( )。

    public class Test {
        private String function(String temp, int data, int sum) {
            return ("GFG");
        }
    
        private String function(String temp, int data) {
            return ("GeeksforGeeks");
        }
    
        public static void main(String[] args) {
            Test obj = new Test();
            System.out.println(obj.function("GFG", 0, 20));
        }
    }
    

    a) GFG
    b) Compilation error
    c) Runtime error
    d) GeeksforGeeks

    参考答案

    ``` a ```

    Question 6 以下程序的输出结果为( )。

    public class Test {
        private String function(float i, int f) {
            return ("gfg");
        }
    
        private String function(double i, double f) {
            return ("GFG");
        }
    
        public static void main(String[] args) {
            Test obj = new Test();
            System.out.println(obj.function(1., 20));
        }
    }
    

    a) GFG
    b) Compilation error
    c) Runtime error
    d) GeeksforGeeks

    参考答案

    ``` a ```

    参考链接

  • 相关阅读:
    Django动态渲染多层菜单
    python使用pdkdf2加盐密码
    ceil 模块
    python面试总结
    Django 中related_name,"%(app_label)s_%(class)s_related"
    安装zabbix-3.0.3+nginx-1.10.1+php-5.6.22
    Django 权限管理
    python RecursionError: maximum recursion depth exceeded in comparison错误
    django _meta方法
    html 之input标签height设置问题
  • 原文地址:https://www.cnblogs.com/hgnulb/p/11342987.html
Copyright © 2011-2022 走看看