Linkedin Java 检定题目分享

前言
在更新Linkedkin 个人档案的时候
偶然发现他有技术检定测验
如果总成绩在前30%,会发给你技术认证徽章
如果第一次没考过可以重考
如果第二次也没考过就要"等半年!!!" 才能考第二次
本文章为真实考题
个人感觉题目有点像OCA的考题,蛮适合正在学习Java观念
或工作一段时间但没深入研究Java的人
如果有需要的人还请自行服用。

Question :
Which code snippet is valid?

  A. Array<String> words = new ArrayList<String>(){"Hello","world"};  B. ArrayList<String> words = new ArrayList<>(Arrays.asList("Hello", "world"));  C. ArrayList<String> words = Arrays.asList("Hello","World");  D. ArrayList<String> words = {"Hello","World"};

anwser: B

解析:
A: 语法错误,无法这样宣告
C: asList方法,返回的型别为List,故编译阶段会出现错误。
D: 这样宣告是一般array的宣告方法,并不是ArrayList的宣告方法

Question :
Which is the most reliable expression for testing whether the values of two string variables are the same?

options:
A. string1.matches(string2)
B. string1.equals(string2)
C. string1 == string2
D. string1 = string2

answer:B

解析:
题目是说何者是Java中最可靠用来比较字串内容的方法
==和equals区别的经典案例
网路上已经有很多教学文章,可自行google


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章