1. In java (What is the output of the code segment)?
public static void Main(){
int x = 38;
int y = 45;
int z = DoIt(ref x,
ref y);
PRINTLINE(x + “ “ + y + “ “ + z); // PRINTLINE
1
}
static int DoIt(ref int a, ref
int b)
{
a /= 6;
b /= 8;
PRINTLINE(a + “ “ + b); // PRINTLINE 2
return (a + b);
}
2.
public static void Main(){
int x = 38;
int y = 45;
int z = DoIt(ref x,
ref y);
PRINTLINE(x + “ “ + y + “ “ + z); // PRINTLINE
1
}
static int DoIt(ref int a, ref
int b)
{
a /= 6;
b /= 8;
PRINTLINE(a + “ “ + b); // PRINTLINE 2
return (a + b);
}
Output1: ----------- 6 5 6 5 11 Output2: ----------- 6 5 6 5 11 Note: Both the program code is same.
1. In java (What is the output of the code segment)? public static void Main(){ ...
What is the output from the following code segment? Output from PRINTLINE 1: public static void Main(){ int x = 38; int y = 45; int z = DoIt(ref x, ref y); PRINTLINE(x + “ “ + y + “ “ + z); // PRINTLINE 1 } static int DoIt(ref int a, ref int b) { a /= 8; b /= 7; PRINTLINE(a + “ “ + b); // PRINTLINE 2 return (a + b);...
What is the output of the PRINTLINE2 from the following code segment? public static void Main(){ int x = 15; int y = 55; int z = DoIt(ref x, ref y); PRINTLINE(x + “ “ + y + “ “ + z); // PRINTLINE 1 } static int DoIt(ref int a, ref int b) { a += 22; b -= 12; PRINTLINE(a + “ “ + b); // PRINTLINE 2 return (a - b); }
What is the output of the following code: public static void main(String []args){ int x = 10; int y = 10; try{ System.out.println(function1(y, x)); } catch (Exception e) { System.out.println(“ERROR”); } } static int function1 (int x, int y) { x += 10; y += 7; return (x + y); }
What is the Java output? Part One: class Driver { public static void main(String[] args) { int a = 5; int b = 3; if (a < b || a * 2 < b) System.out.print(a - b); System.out.print(b + a); } } Part Two: class Driver { public static void main(String[] args) { int a = 5; int b = 8; if (a < b) if (a * 2 < b) System.out.print("foo"); else System.out.print("bar"); else System.out.print("buz"); } }
What will be the output of the following Java code? class Output { public static void main(String args[]) { boolean a = true; boolean b = false; boolean c = a ^ b; System.out.println(!c); } } a) 0 b) 1 c) false d) true
Find the following java program's 9 syntax errors. public class Parameters { public static void main() { double bubble = 867.5309; double x = 10.01; printer(double x, double y); printer(x); printer("barack", "obama"); System.out.println("z = " + z); } public static void printer(x, y double) { int z = 5; System.out.println("x = " + double x + " and y = " + y); System.out.println("The value from main is: " + bubble); }
What output is produced by the following program? public class MysteryNums public static void main(String[] args) - int x = 12; int y = x - 3; 3, sentence (y, x + y); . public static void sentence (int numi, int num2) { 4: System.out.println(num1 + " + num2);
1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...
Show the output of the following piece of code: public static void main(String[] args) { char x = 'a'; char y = 'c'; System.out.println(++x); System.out.println(y++); System.out.println(x - y); }
X. (10 points) In the box provided show the output for this program segment public static void main (String [) args) intl num-(1,2.3,4) System.out printinx+y+num12) tyit(y, x. num): System.out printin(x+ynum(2): public static void tryit(int a, int b, intl c) int x c[2]-20 System.out printin(x+bCI2) XI. (7 points) a. Write a method NEGATIVE that receives as parameters a one-dimensional array variable LIST of integers. The method should return the sum of the negative elements in the array. You may not assume...