java程序员个人能力介绍_Java操作员能力问题
java程序員個(gè)人能力介紹
Java Operators Aptitude Questions and Answers: This section provides you Java Operators related Aptitude Questions and Answers with multiple choices. Here, You will get solution and explanation of each question.
Java操作員能力傾向問(wèn)題和解答 : 本部分為您提供了與Java操作員有關(guān)的能力傾向問(wèn)題和解答的多種選擇。 在這里,您將獲得每個(gè)問(wèn)題的解決方案和解釋。
Java操作員能力傾向問(wèn)題列表 (List of Java Operators Aptitude Questions and Answers)
1) What will be the output of following program ? class Opr {public static void main(String args[]){boolean ans=false;if(ans=true)System.out.print("Done");elseSystem.out.print("Fail");} }Done
Fail
Error
DoneFail
Correct Answer: 1
Done
in condition ans=true, the value of ans becomes true hence condition is true.
1)以下程序的輸出是什么?完成了
失敗
錯(cuò)誤
完成失敗
正確答案:1
完成了
在條件ans = true時(shí) , ans的值變?yōu)閠rue,因此條件為true 。
2) What will be the output of following program? class Opr {public static void main(String args[]){int x=5,y;y= ++x + x++ + --x;System.out.println(x + "," + y);} }6,15
6,18
6,12
None of these
Correct Answer: 2
6, 18
In JAVA ++/-- operators evaluates with expression Rule to evaluate expression with ++/-- : [pre_increment -> expression ->post_increment] Consider the expression,
y=++x + x++ + --x; => y=6 + 6 + 6;
here, ++x evaluates first, value of x will be 6, x++ evaluates after adding starting two terms ++x + x++ [6+6], and then x will be 7 (due to x++), --x will evaluate before adding value in previous result, so expression will solve like 6+6+6.
6,15
6,18
6,12
都不是
正確答案:2
6、18
在JAVA中,+ /-+ /-運(yùn)算符使用表達(dá)式Rule來(lái)評(píng)估++ /-: [pre_increment-> expression-> post_increment]考慮表達(dá)式,
y = ++ x + x ++ + --x; => y = 6 + 6 + 6;
在這里,++ x首先求值,x的值為6,x ++在加上兩個(gè)開(kāi)始項(xiàng)之后求值++ x + x ++ [6 + 6],然后x將為7(由于x ++),--x將求值在之前的結(jié)果中添加值之前,表達(dá)式將像6 + 6 + 6一樣求解。
110, 110
10, 110
10, 10
None of these
Correct Answer: 2
10, 110
Here variable a in main and a in assign are different, only value of a (10) will pass into function assign, value of a will remain same, answer will 10, 110.
3)以下程序的輸出是什么?110、110
10、110
10、10
都不是
正確答案:2
10、110
這里變量a in和main的賦值是不同的,只有a的值(10)會(huì)傳遞給函數(shù)assign,a的值將保持不變,答案將為10、110。
4) What will be the output of following program? class Opr {public static void main(String args[]){int a,b,result;a=10; b=20;result=(b>=a);System.out.print(result);} }Error
1
True
20
Correct Answer: 1
ERROR: incompatible types.
Consider the expression result=(b>=a); here value of b is largest from a, True will return, and true (boolean) can not assign into integer variable.
4)以下程序的輸出是什么?錯(cuò)誤
1個(gè)
真正
20
正確答案:1
錯(cuò)誤:不兼容的類型。
考慮表達(dá)式result =(b> = a) ; 此處b的值是a的最大值,True將返回,并且true(布爾)不能分配給整數(shù)變量。
5) What will be the output of following program? class Opr {public static void main(String args[]){int a,b,result;a=10; b=20;result=(int)(b>=a);System.out.print(result);} }Error
1
True
20
Correct Answer: 1
ERROR: incompatible types.
Consider the expression result=(int)(b>=a); .boolean is not convertible to int.
5)以下程序的輸出是什么?錯(cuò)誤
1個(gè)
真正
20
正確答案:1
錯(cuò)誤:不兼容的類型。
考慮表達(dá)式result =(int)(b> = a); .boolean不能轉(zhuǎn)換為int。
Page 2
第2頁(yè)
翻譯自: https://www.includehelp.com/java-aptitude/java-aptitude-operators-questions-and-answers.aspx
java程序員個(gè)人能力介紹
總結(jié)
以上是生活随笔為你收集整理的java程序员个人能力介绍_Java操作员能力问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python字符串转义序列_Python
- 下一篇: python二分法查找程序_Python