Daryan997

exam_fina_programming

Oct 23rd, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. Q1/
  2. 1. B (null)
  3. 2. C (a[0][2])
  4. 3. A (boolean)
  5. 4. C (Switch-case)
  6. 5. D (All of them)
  7. 6. A (for)
  8. 7. C (\n)
  9. 8. B (if(grade!=1))
  10. 9. index
  11. 10. D (column,row)
  12.  
  13. Q2/A
  14.  
  15. 1. switch => Switch is a condition for switch-case statement, where the you write cases for it.
  16.  
  17. 2. index => index is a position of an array element, starts from 0 to length of the array minus one.
  18.  
  19. 3. Multidimensional arrays with two dimensions are often used to represent tables of values consisting of information arranged in rows and columns.
  20.  
  21. 4. nested loop => A nested loop is a loop that appears in the loop body of another loop.
  22.  
  23. 5. repetition statement => repetition statements that enable programs to perform statements repeatedly as long as a condition remains true.
  24.  
  25. Q2/B
  26. 1. False - String value
  27. 2. False - ||
  28. 3. False - %s
  29. 4. True
  30. 5. False - We don't need loop statement
  31. 6. True
  32. 7. True
  33. 8. False - without using counter value
  34. 9. True
  35. 10. False - Can Store Only one type of value
  36.  
  37. Q3/A
  38. Counter-controlled repetition is often called definite repetition, because the number of repetitions is known before the loop begins executing.
  39.  
  40. Sentinel-controlled repetition is often called indefinite repetition because the number of repetitions is not known before the loop begins executing.
  41.  
  42. Q3/B
  43. package javaapplication80;
  44.  
  45. public class JavaApplication80 {
  46.  
  47. public static void main(String[] args) {
  48. int[][] a = {{0,1,2}, {3,4,5}, {6,7,8}, {9,10,11}};
  49. for (int row = 0; row < a[0].length; row++) {
  50. int total = 0;
  51. for (int col = 0; col < a.length; col++) {
  52. total += a[col][row];
  53. }
  54. System.out.println("Col" + row + ": " + total);
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment