Category: Uncategorized
Java 2022 Solution || BIM STUDY Notes
// Q.N0 11) TO FIND THE SECOND HIGHEST VALUE IN AN ARRAY
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
package bimnotessolutions; public class Regular2022 { public static void main(String[] args) { int a[] = {1,2,3,4,5}; for(int i=0;i<a.length;i++){ for(int j = i+1;j<a.length;j++){ if(a[i]>a[j]){ int temp = a[i]; a[i] = a[j]; a[j] = temp; } } } int index = a.length-2; System.out.println("the second largest value is :"+a[index]); } } |
// Q.N0 12)
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 29 |
package bimnotessolutions; class Product{ private String name; private int qty,price; public Product(String name, int qty, int price) { this.name = name; this.qty = qty; this.price = price; } public String getName() { return name; } public int getQty() { return qty; } public int getPrice() { return price; } public int getTotal(){ return this.getQty()*this.getPrice(); } } public class Regular2022 { public static void main(String[] args) { Product p1 = new Product("bread",2,500); Product p2 = new Product("muffins",4,600); System.out.println("the total sum is :"+(p1.getTotal()+p2.getTotal())); } } |
// Q.N0 13) implementing thread using Runnable class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
package bimnotessolutions; class ThreadExample implements Runnable{ public void run(){ try{ for(int i = 100 ; i <=200 ; i++){ Thread.sleep(1500); if(i%2==0){ System.out.print(i+" "); } } }catch(Exception err){ System.out.println(err); } } } public class Regular2022 { public static void main(String[] args) { ThreadExample te = new ThreadExample(); Thread t1 = new Thread(te); t1.start(); } } |
Q.NO 15)
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 29 30 31 |
package bimnotessolutions; class MyException extends Exception{ MyException(String msg){ super(msg); } } class Person{ private String name; private int age; public void setName(String name){ this.name = name; } public void setAge(int age) throws MyException{ if(age<0 || age>100){ throw new MyException("age should be between the age"); } else{ this.age =age; } } } public class Regular2022 { public static void main(String[] args) throws MyException { Person p = new Person(); p.setName("Ram"); try{ p.setAge(150); }catch(MyException err){ System.out.println(err); } } |
Continue Reading
web 2022 Solution || BIM Study Notes
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 29 30 31 32 33 |
<!DOCTYPE html> <html lang="en"> <head> <title>Document</title> <style> table,td,th{ border: 1px solid black ; border-collapse: collapse; } </style> </head> <body> <table> </table> <script> var students = [[1,"Arbind","bim"],[1,"bishal","bhm"],[1,"raju","csit"],[1,"ram","bbm"],[1,"sam","bbm"]] var table=`` table+=`<tr> <th>roll</th> <th>name</th> <th>faculty</th> </tr>` for(var i = 0 ; i < students.length;i++){ table+=`<tr> <td>${students[i][0]}</td> <td>${students[i][1]}</td> <td>${students[i][2]}</td> </tr>` } var data = document.querySelector("table") data.innerHTML=table </script> </body> </html> |
Q.NO 12) javaScript code to check if the given number is multiple of 5 or not
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<!DOCTYPE html> <html lang="en"> <head> <title>Document</title> </head> <body> <form> Enter the number : <input type="text" name="number" id="number"> <button>check</button> </form> <script> var button = document.querySelector("button") button.addEventListener('click',(e)=>{ e.preventDefault() var number = parseInt(document.getElementById('number').value) if(number%5==0)alert("It is the multiple of 5") else alert("It is not the multiple of 5") }) </script> </body> </html> |
Q.NO 14) HTML code to generate the following table
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 |
<!DOCTYPE html> <html lang="en"> <head> <title>Document</title> </head> <style> table,td{ border:1px solid black; border-collapse: collapse; padding:20px; } </style> <body> <table> <tr> <td></td> <td rowspan="2"></td> <td></td> </tr> <tr> <td></td> <td></td> </tr> </table> </body> </html> |
Q.NO 16 ) Example to show client side validation
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 29 |
<!DOCTYPE html> <html lang="en"> <head> <title>Document</title> </head> <body> <form> username : <input type="text" name="username" id="username"> <br> password : <input type="text" name="password" id="password"> <br> contact : <input type="text" name="contact" id="contact"> <br> <button name="submit" id="submit">submit</button> </form> <script> var button = document.querySelector("#submit") button.addEventListener('click',(e)=>{ e.preventDefault() var username= document.getElementById('username').value var password= document.getElementById('password').value var contact= document.getElementById('contact').value var usernameRegex =/^([a-zA-Z])+([0-9]?)+$/ var passwordRegex = /^[A-Za-z0-9]{6}$/ var contactRegex = /^([0-9]){10}$/ if(username.match(usernameRegex) && password.match(passwordRegex) && contact.match(contactRegex)) alert('success') else alert('fail') }) </script> </body> </html> |
Continue Reading