JAVA 2016 Old Papers Solutions
Year 2016 Q.no 11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
public class tu16Q11 { public static void main(String[] args) { int [] a={1,22,23,3,4,67,87,23,56,35,47,5,61,7,80,9,23,23,45,456,345,67,0,23,45,67,87,1,3,4}; for(int i=0;i<30;i++){ if(a[i]>16 &&a[i]<47){ System.out.println(a[i]); } } } } or /** * * @author bim study notes */ import java.util.*; public class ArrayDemo { public static void main(String[] args) { int arr[] = new int[30]; Random r = new Random(); int i; for(i=0;i<arr.length;i++){ int num = r.nextInt()%50; arr[i] = num; } for(i=0;i<arr.length;i++){ if(arr[i]>16&&arr[i]<47) System.out.print(arr[i]+" "); } } } |
Q.no 12 Create two classes ThreadA and ThreadB which implement Runnable interface. ThreadA displays all even numbers from 50 to 100 and ThreadB displays all odd numbers from 100 to 200. Define a main class which creates the objects of both the classes and displays the numbers as per […]
Continue Reading