笔试题 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
```

参考链接

【笔试题】Overloading in Java的更多相关文章

  1. Java 面试/笔试题神整理 [Java web and android]

    Java 面试/笔试题神整理 一.Java web 相关基础知识 1.面向对象的特征有哪些方面 1.抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并 ...

  2. 剑指Offer——CVTE校招笔试题+知识点总结(Java岗)

    剑指Offer(Java岗)--CVTE校招笔试题+知识点总结 2016.9.3 19:00参加CVTE笔试,笔试内容如下: 需要掌握的知识:Linux基本命令.网络协议.数据库.数据结构. 选择题 ...

  3. 一道笔试题来理顺Java中的值传递和引用传递

      题目如下: private static void change(StringBuffer str11, StringBuffer str12) { str12 = str11; str11 = ...

  4. 【笔试题】在 Java 中,如何跳出当前的多重嵌套循环?

    笔试题 在 Java 中,如何跳出当前的多重嵌套循环? public class Demo { public static void main(String[] args) { System.out. ...

  5. 笔试题二(java面向对象、多线程、集合)

    1.final关键字的特点 final修饰变量时,在堆内存中的地址是不变的,但对象的内容是可变的.//思考,找例子 2.静态变量的特点 实例变量是用对象引用,要先实例化对象,而静态变量属于类,只要类加 ...

  6. Java 工程师面试题和笔试题整理(一)

    根据自己之前收集的还有一部分自己面试的整理出来,希望能帮到面试的兄弟(2017). 海科融通 笔试题 1.有一个字符串,如果要在其中查找一个子串,都有哪些方式,写出你认为最好的一个. 2.写出线程都有 ...

  7. 【笔试题】Overriding in Java

    笔试题 Overriding in Java Question 1 以下程序的输出结果为( ). class Derived { protected final void getDetails() { ...

  8. Android开发面试经——3.常见Java基础笔试题

      Android开发(29)  版权声明:本文为寻梦-finddreams原创文章,请关注:http://blog.csdn.net/finddreams 关注finddreams博客:http:/ ...

  9. 2016最新Java笔试题集锦

    更新时间:2015-08-13         来源:网络         投诉删除 [看准网(Kanzhun.com)]笔试题目频道小编搜集的范文“2016最新Java笔试题集锦”,供大家阅读参考, ...

随机推荐

  1. kuma 学习四 策略

    通过策略我们可以构建灵活的service mesh 应用策略 我们可以通过kumactl 以及kubectl 应用策略 kumactl 格式 echo " type: .. spec: .. ...

  2. go中的事件对象time.Duration

    const ( Nanosecond Duration = 1 Microsecond = 1000 * Nanosecond Millisecond = 1000 * Microsecond Sec ...

  3. Linux 系统管理——系统安全及应用

    chagen -d 0 ____用户名:下次登录时必须修改密码 ctrl+R:查看历史记录 history:查看历史记录 清除历史记录: >.bash _history echo“”>.b ...

  4. 服务器使用ssh秘钥登录并禁止密码登录

    问题: 最近在登录服务器的时候,每次都会有提示999+ falied login等字眼,意思就是自己的服务器密码正在被人暴力破解.想象以下,别人有了你的服务器的root登录密码,那么就可以对你的服务器 ...

  5. MYSQL避免重复插入记录的三种方法

      方案一:使用ignore关键字 如果是用主键primary或者唯一索引unique区分了记录的唯一性,避免重复插入记录可以使用: insert ignore into table_name(ema ...

  6. select多选左移右移的实现

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  7. 三个面向对象相关的装饰器@property@staticmathod@classmethod

    @property 先看实例: from math import pi class Circle: def __init__(self,r): self.r = r @property def per ...

  8. Win7下如何使用tracert命令查看网络状况?

    大家平时在访问的网站中,是不是有一些网站访问速度很快,而有些网站却访问的很慢呢?甚至有些网站无法访问.那你们知道该怎么判断这些网站的访问速度呢?不知道的话,那就使用Windows的tracert命令来 ...

  9. Curiosity-Driven Learning through Next State Prediction

    Curiosity-Driven Learning through Next State Prediction 2019-10-19 20:43:17 This paper is from: http ...

  10. php 加载 zip 文件

    header('Content-type: application/zip');header('Content-Disposition: attachment; filename="Quer ...