Java面试问题 021-030
原文来自http://www.allapplabs.com/interview_questions/java_interview_questions.htm
翻译:Zeng Yuetian
转载请注明出处。
Q021: |
How can one prove that the array is not null but empty using one line of code? |
A: |
Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length. |
Q022: |
What environment variables do I need to set on my machine in order to be able to run Java programs? |
A: |
CLASSPATH and PATH are the two variables. |
Q023: |
Can an application have multiple classes having main method? |
A: |
Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method. |
Q024: |
Can I have multiple main methods in the same class? |
A: |
No the program fails to compile. The compiler says that the main method is already defined in the class. |
Q025: |
Do I need to import java.lang package any time? Why ? |
A: |
No. It is by default loaded internally by the JVM. |
Q026: |
Can I import same package/class twice? Will the JVM load the package twice at runtime? |
A: |
One can import the same package or same class multiple times. Neither compiler nor JVM complains abt it. And the JVM will internally load the class only once no matter how many times you import the same class. |
Q027: |
What are Checked and UnChecked Exception? |
A: |
A checked exception is some subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses. 查核异常要求客户端程序员处理异常将被抛出的可能性。例如:IOException可能会被java.io.FileInputStream中的read()方法抛出 |
Q028: |
What is Overriding? |
A: |
When a class defines a method using the same name, return type, and arguments as a method in its superclass, the method in the class overrides the method in the superclass. 当一个类定义了一个方法,该方法和它的父类中的同名方法有着相同的返回类型和相同的参数,那么该类的这个方法覆盖了它父类中的那个同名方法。 |
Q029: |
Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile? |
A: |
Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying,can not resolve symbol symbol : class ABCD |
Q030: |
Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*? |
A: |
No you will have to import the subpackages explicitly. Importing com.MyTest.* will import classes in the package MyTest only. It will not import any class in any of it's subpackage. |
转载于:https://www.cnblogs.com/yuetiantian/archive/2010/02/03/1663016.html
Java面试问题 021-030相关推荐
- java面试常见问题之Hibernate总结
1 Hibernate的检索方式 Ø 导航对象图检索(根据已经加载的对象,导航到其他对象.) Ø OID检索(按照对象的OID来检索对象.) Ø HQL检索(使用面向对象的HQL查询语言.) ...
- 2021年Java面试题目最新总结【90%面试会踩的坑】
学会java技术之后大家面临的最多的问题就是面试这关,求职面试java岗位是否能够成功是直接影响我们的工作机会的,所以对于Java程序员面试你准备好了吗?今天小编汇总了一下关于Java程序员面试,90 ...
- Github 一夜爆火:这份金九银十 Java 面试手册我给跪了
这几天给筒子们整理了一份<Java面试手册>,106页,目前大约6万字左右,初衷也很简单,就是希望在面试的时候能够帮助到大家,减轻大家的负担和节省时间. 废话不多说,本手册目前为第一版,后 ...
- Java面试参考指南(二)
2019独角兽企业重金招聘Python工程师标准>>> 访问修饰符 对于基本的OOPS(面向对象)概念,请看Java面试参考指南的第一部分.访问修饰符规定了一个类如何访问另一个类及它 ...
- 卧槽,又一个Java面试神器!!!
临近秋招,又到了"金九银十"面试求职高峰期,在金三银四时也参与过不少面试,2020都说工作不好找,也是对开发人员的要求变高.前段时间自己有整理了一些Java后端开发面试常问的高频考 ...
- 200 道 Java 面试题解!某阿里 P7 只答上来 70%!
最近,经常有读者朋友们在后台给我留言,问我有没有什么面试资料可以分享的,因为之前一直比较忙,所以没有时间整理. 最近终于抽出一些时间,整理了一下,一发不可收拾了,一口气整理出好几本电子书出来.其中有一 ...
- 美团架构师开源5万字的《Java面试手册》PDF免费下载!
美团一位架构师利用空余时间在github整理了一份<Java面试手册>,现整理成PDF,初衷也很简单,就是希望在面试的时候能够帮助到大家,减轻大家的负担和节省时间. 前两天,朋友圈分享了这 ...
- 5万字的《Java面试手册》V1.0版本,高清PDF免费获取
利用空余时间整理了一份<Java面试手册>,初衷也很简单,就是希望在面试的时候能够帮助到大家,减轻大家的负担和节省时间. 前两天,朋友圈分享了这份这份面试手册的初稿,再几位同学的提议下,对 ...
- JAVA面试解析(有赞二面)
作者:孤独烟 来自:打杂的ZRJ 本文的题目出自博客 http://www.54tianzhisheng.cn/2018/07/12/youzan/ 但是作者没有给出答案,博主斗胆来制作答案版. 也是 ...
- Java 面试,这样拿 Offer!
(含答案) 所有面试资料及技术好文精选文档都整理到网盘了. Java面试官手册需要加微信免费领取 长按扫码或搜索微信号:gupao666666,免费领取
最新文章
- oracle导入索引b报错,impdp导入索引很慢
- eclipse常用快捷键Get;set;
- zookeeper 伪分布式安装
- Expert 诊断优化系列------------------透过等待看系统
- SQL编程:模糊表关联不求人 --- concat + like就能行
- RTC_WaitForSynchro()
- 运行时异常与一般异常有何异同_Java修行第015天,异常机制和常用类
- 【C++】考虑virtual函数以外的其他选择
- 萤火虫小程序_9.9元起!萤火虫中秋文化节来了!特价门票限量秒杀,手慢无!...
- android tcpdump log分析,android 系统启动过程中加入tcpdump和logcat
- 这份 Pandas 学习教程很不错,可在线运行
- 算法题3 二分查找法
- 学习面试题(day01)
- TCP/IP之封装,分用,server模型
- Windows Phone 7, Hammock, OAuth and Sina Weibo’s API
- 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_01 File类_4_File类的构造方法...
- 亿欧:深耕开放银行,Temenos产品创新和并购战略双轮驱动
- Python基于OpenCV的人脸集合相似度检测系统(源码&UI&教程)
- chrome禁止广告
- 一款强大的网站在线客服聊天系统:whisper搭建教程
热门文章
- caffe测试单张图片
- 查找python关键字
- 新版微信不停跳转到小程序_微信又有大动作,小程序跳转功能将受限?
- 2021-07-07 分类页面结构
- 为什么天才容易患阅读障碍症_王俊凯因“耳石症”缺席跨年晚会,这种病与熬夜玩手机有关?...
- 联想提取exe文件中的bios文件_3900不带X能干过99K吗?品牌机做视频渲染可以?联想刃7000P评测...
- kubernetes service的作用、类型、关系和工作原理ClusterIp、NodePort、LoadBalance、ExternalName
- 基于springboot+vue的二手商城(闲置物品交易)(前后端分离)
- MRTK 当进入某个物体时调用的函数
- Leetcode994腐烂的橘子(宽搜)