Tag: 3rd Sem BIM Notes
JAVA 2015 Old paper Solutions
Year 2015 Group B Q.no 11 Write a Java Program to display all the even numbers from 1 to 500
1 2 3 4 5 6 7 8 9 10 11 |
public class tu15Q11 { public static void main(String[] args) { int i; for(i=1;i<=500;i++){ if(i%2==0){ System.out.println(i); } } } } /** * * @author bim study notes */ |
12. Make a thread using Runnable interface to display numbers from 1 to 20, each number should be displayed in the interval of 2 seconds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
class ThreadNum implements Runnable{ public void run(){ try{ for(int i=1;i<=20;i++){ System.out.print(i+" "); Thread.sleep(2000); } }catch(InterruptedException e){ System.out.println("Thread Interrupted"); } } } /** * * @author bim study notes */ public class EvenNumThreadDemo { public static void main(String[] args) { ThreadNum n = new ThreadNum(); Thread t = new Thread(n); t.start(); } } |
13. Write a program that reads line of […]
Continue ReadingJAVA Model Questions || BIM STUDY NOTES
Model Questions Write a Java program to display all the numbers between -300 to -1 which when divided by 17 gives 7 as remainder and also displays sum of those numbers.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public class Sum { public static void main(String[] args) { int i,s=0; for(i=-300;i<-1;i++) { if(i%17==-7){ System.out.print(i+ " "); s = s+i; } } System.out.println("The sum = "+s); } } |
3.Make two threads, one displays odd number after one second and another thread display even number after half second between -200 and -10. […]
Continue ReadingSt Xavier’s College Pre board 2021 || BIM STUDY NOTES
< St Xavier’s College Pre board 2021 || BIM STUDY NOTES
Continue Reading