these are java programming... please write the output of these code without running the code....Part-B It's fill in the
Posted: Mon Jun 06, 2022 5:57 pm
these are java programming... please write the output of these code without running the code....Part-B It's fill in the gaps..IT'S urgent give all anwers...and explain the answer if you can...
(5) (6) class StaticTest { static int x = 1; int y: StaticTest() { y++; public static void main(String args[]) { StaticTest st = new StaticTest (); System.out.println("x=" + x); y=" + st. y); System.out.println("st. st= new StaticTest(); System.out.println("x=" + x); System.out.println("st. y=" + st. y); static { x++; public class StringArrayTest{ public static void swap (String [] s) { if (s. length<2) return; String t-s[0]; s[0]=s[1]: s[1]=t; } public static void main (String args[]) { String [] s ("1", "2"); swap (s); System.out.print (s[0]+s[1]): }
(7) class TestExcepRoute { public static void main(String [] args) { try { method (); } catch (Exception e) { System.out.print('m'); } System.out.println('n'); } static void createException () { throw new Array IndexOutOfBoundsException(); } static void method () { try { createException(); System.out.print('a'); } catch (ArithmeticException e) { System.out.print('b'); } finally { System.out.print('c'); } System.out.print('d'); }
(8) class StudentFinal { private final long Student ID; private static long number=2007030801; public Student Final () { Student ID number++; public long getID() { return Student ID; } public static void main(String[] args) { StudentFinal [ ] s = new Student Final [3]; for (int i=0; i<s. length; i++) { s=new Student Final (); System.out.println("The Student ID is "+s.getID());
B. Read the following program code carefully, and complete the statements underlined (1) to (5) abstract class Person! private String name; public Person (String n) { name = n; } public. String getMajor (); 0 ( public String (2) return name; } 1 class Student (3) Person ( private (4) public Student (String n, String m) { super (n): major = m; 1 public String (5) return "major is :" + major; _0 ( public class TestPerson! public static void main(String args[]) { Person p = new Student ("tom", "AI engineering"); System.out.println (p. getName()+", "+p. getMajor (());
(5) (6) class StaticTest { static int x = 1; int y: StaticTest() { y++; public static void main(String args[]) { StaticTest st = new StaticTest (); System.out.println("x=" + x); y=" + st. y); System.out.println("st. st= new StaticTest(); System.out.println("x=" + x); System.out.println("st. y=" + st. y); static { x++; public class StringArrayTest{ public static void swap (String [] s) { if (s. length<2) return; String t-s[0]; s[0]=s[1]: s[1]=t; } public static void main (String args[]) { String [] s ("1", "2"); swap (s); System.out.print (s[0]+s[1]): }
(7) class TestExcepRoute { public static void main(String [] args) { try { method (); } catch (Exception e) { System.out.print('m'); } System.out.println('n'); } static void createException () { throw new Array IndexOutOfBoundsException(); } static void method () { try { createException(); System.out.print('a'); } catch (ArithmeticException e) { System.out.print('b'); } finally { System.out.print('c'); } System.out.print('d'); }
(8) class StudentFinal { private final long Student ID; private static long number=2007030801; public Student Final () { Student ID number++; public long getID() { return Student ID; } public static void main(String[] args) { StudentFinal [ ] s = new Student Final [3]; for (int i=0; i<s. length; i++) { s=new Student Final (); System.out.println("The Student ID is "+s.getID());
B. Read the following program code carefully, and complete the statements underlined (1) to (5) abstract class Person! private String name; public Person (String n) { name = n; } public. String getMajor (); 0 ( public String (2) return name; } 1 class Student (3) Person ( private (4) public Student (String n, String m) { super (n): major = m; 1 public String (5) return "major is :" + major; _0 ( public class TestPerson! public static void main(String args[]) { Person p = new Student ("tom", "AI engineering"); System.out.println (p. getName()+", "+p. getMajor (());