Software Programming : Java Programming QUESTIONS AND ANSWERS :: part9 : 11 to 15
Following Software Programming language Entrance Multiple choice objective type questions and answers will help you in Software Programming 2024 examinations :
11.Analyze the following code: public class Test { public static void main(String[] args) { int[] x = new int[5]; int i; for (i = 0; i < x.length; i++) x[i] = i; System.out.println(x[i]); } } |
The program displays 0 1 2 3 4 |
The program displays 4 |
The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBoundsException |
The program has syntax error because i is not defined in the last statement in the main method |
The program displays 1 2 3 4 5. |
12.You may or may not recall that the standard Java computing environment contains a Math class that includes a method called random() which returns a double as described below: public class Math { // The following method returns a double value with a // positive sign, greater than or equal to zero, // but less then 1.0, chosen "randomly" with approximately // uniform distribution from that range. public static double random() { ... } ... } Which one of the following expressions has a value that is equally likely to have any integer value in the range 3..8? |
(6 * (int)Math.random()*100) + 3 |
(Math.random()*100 / (int) 6) + 3 |
(3..8 * Math.random()*100) |
(int)(Math.random()*100 % 6) + 3 |
(6 / (int) Math.random()*100) + 3. |
13.A proposed graduated state income tax applies the following rate schedule to net income after deductions: 0 --- if the net income is negative #2% --- on incomes less than $10,000 $200, plus 4% of excess over $10,000 --- for incomes between $10,000 and $20,000 (inclusive) $600, plus 6% of excess over $20,000 --- for incomes between $20,000 and $30,000 (inclusive) $1,200, plus 8% of excess over $30,000 --- for incomes greater than $30,000 You have been given a program that is supposed to calculate the tax on a given income in dollars. Which one of the following is the best set of test data on which to try out this program? |
it makes no difference, any of the following are equally good! |
2000, 4000, 6000, 8000, 10000, 12000, 14000 |
-10, 75, 10000, 15000, 20000, 25000, 30000, 40000 |
0, 10000, 20000, 30000, 40000 |
-5000, 0, 5000, 15000, 25000, 35000. |
14.Suppose the following Java statements: char ch = ' '; try {do {ch = (char) System.in.read(); } while ( ch != 'G'); } catch(Exception i) { System.out.println(ch); } are executed and applied to the following input which is typed on the keyboard: g MnGyZ The final value of the variable ch will be: |
'g' |
' ' |
'n' |
'G' |
'y'. |
More Java Programming QUESTIONS AND ANSWERS available in next pages
-
Health is the greatest gift, contentment is the greatest wealth -Buddha
- TNTET 2021 - Practice
- SSC CGL 2021 - Practice
- TNPSC Group 2A 2021 - Practice
- IIT JEE
- IIT JEE Q&A
- TNPSC Answer Keys
- TNPSC Group 2 Syllabus
- TNPSC Q&A
- Online Tests - TNPSC
- Online Tests - GK
- IBPS 2020-2021
- Online Tests - Bank
- Online Tests - RRB NTPC
- Online Tests - UGC NET
- Online Tests - TANCET
- Online Aptitude Test
- Engineering
- Programming
- Basic Science
- Quiz
- Plus Two Question Papers
- SSLC Question Bank
- Aptitude Tests
- Logical Reasoning
- General Knowledge-Hindi
- Indian History MCQ
- Indian Geography MCQ
- Indian Civics MCQ
- Indian Economics MCQ
- CTET Biology MCQ
- CTET Chemistry MCQ
- CTET Physics Solved MCQ
- Arithmetic Tests
- Press Release
- FAQ
- Coaching Centres
- TNPSC Group 1 Syllabus
- TNPSC Group IV Syllabus
- TRB 2017 in English PDF
- TRB 2017 in Tamil PDF
- TET
- TNTET