ITS Certification (Java) Review PDF
Document Details
Uploaded by EnrapturedParabola
Tags
Summary
This document is a review session for the ITS certification exam. It covers various topics relating to Java programming and contains review questions. The document includes multiple-choice questions and coding exercises.
Full Transcript
ITS CERTIFICATION (JAVA) Review Session The Information Technology Specialist program allows students to validate entry-level IT skills that employers are looking for. The IT Specialist program is designed for candidates who are considering or have recently begun a ca...
ITS CERTIFICATION (JAVA) Review Session The Information Technology Specialist program allows students to validate entry-level IT skills that employers are looking for. The IT Specialist program is designed for candidates who are considering or have recently begun a career in information technology. Students can earn certification in a variety of IT topics, including software development, database administration, networking and security, mobility and device management, and coding. Information Technology Specialist Java Examination Java Candidates for this exam are application developers working with Java 6 SE or later, secondary and immediate-post-secondary students of software development, or entry-level software developers. Information Technology Specialist HTML and CSS Examination Exam Coverage: Java Fundamentals Data Types, Variables, and Expressions Flow Control Implementation Object-Oriented Programming Code Compilation and Debugging Information Technology Specialist HTML and CSS Examination The Exam: Number of Questions: 40 Question Types: Multiple Choice Duration: Up to 50 minutes Review Questions IT Specialist Java Evaluate the following exception: Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 5 at itsjava.Program.arrayDisplay(Program.java: 31) at itsjava.Program.beginProcess(Program.java: 23) at itsjava.Program.main(Program.java: 18) For each statement select True or False True False The root cause of the exception is in the method beginProcess An error occurred on line 31 Three methods were invoked before the error occurred The stack trace that the exception was caused by a syntax error IT Specialist Java Evaluate the following exception: Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 5 at itsjava.Program.arrayDisplay(Program.java: 31) at itsjava.Program.beginProcess(Program.java: 23) at itsjava.Program.main(Program.java: 18) For each statement select True or False True False The root cause of the exception is in the method beginProcess An error occurred on line 31 Three methods were invoked before the error occurred The stack trace that the exception was caused by a syntax error IT Specialist Java Review the following code: public class Main { public static void main (String args []) throws ArrayIndexOutOfBoundsException { try { int d = 0; int n = 20; int fraction = n / d; int g[] = {1}; g = 100; System.out.println ("The fractional result " + fraction); } catch (ArithmeticException e) { System.out.println("Exception due to "+ e); } catch (RuntimeException e) { System.out.println("Exception due to "+ e); } } } What is the output? A. The fractional part result : 20 B. Exception due to java.lang.ArithmeticException / by Zero C. Exception due to java.lang.RuntimeException: Index 10 out of bounds for length 1 D. Exception due to java.lang.ArrayIndexOutOfBoundsException: Index 10 out of bounds for length 1 IT Specialist Java Review the following code: public class Main { public static void main (String args []) throws ArrayIndexOutOfBoundsException { try { int d = 0; int n = 20; int fraction = n / d; int g[] = {1}; g = 100; System.out.println ("The fractional result " + fraction); } catch (ArithmeticException e) { System.out.println("Exception due to "+ e); } catch (RuntimeException e) { System.out.println("Exception due to "+ e); } } } What is the output? A. The fractional part result : 20 B. Exception due to java.lang.ArithmeticException / by Zero C. Exception due to java.lang.RuntimeException: Index 10 out of bounds for length 1 D. Exception due to java.lang.ArrayIndexOutOfBoundsException: Index 10 out of bounds for length 1 IT Specialist Java Complete the branching sentences about working with branching statements in Java by selecting the correct words below. unlabeled break labeled break continue To terminate the inner loop of a nested loop use a _______________ statement. To terminate the outer loop of a nested loop use a _______________ statement. To jump to the next iteration of an inner loop, use a ______________ statement IT Specialist Java Complete the branching sentences about working with branching statements in Java by selecting the correct words below. unlabeled break labeled break continue To terminate the inner loop of a nested loop, use an unlabeled break statement. The unlabeled break exits the innermost loop it is inside. To terminate the outer loop of a nested loop, use a labeled break statement. A labeled break allows you to specify which loop to terminate by labeling it. To jump to the next iteration of an inner loop, use a continue statement. The continue statement skips the remaining code in the current iteration and moves to the next iteration. IT Specialist Java You are writing a Java method. The method must perform the following task. Accept an int parameter named age Assign the senior classification if age if 65 or higher Assign the adult classification if age is 20 or higher but lower than 65 Otherwise, assign the youth classification public static String ageClassification(int age) { String classification; ______________ classification = "senior"; ______________ classification = "adult"; ______________ classification = "youth"; return classification; } IT Specialist Java You are writing a Java method. The method must perform the following task. Accept an int parameter named age Assign the senior classification if age if 65 or higher Assign the adult classification if age is 20 or higher but lower than 65 Otherwise, assign the youth classification public static String ageClassification(int age) { String classification; if (age >= 65) classification = "senior"; else if (age >= 20) classification = "adult"; else classification = "youth"; return classification; } IT Specialist Java Review the following code: public class Main { What is the output of the program? public static void main (String [] A. 20 18 15 9 args) B. 40 15 20 9 18 { C. ArrayIndexOutOfBounds int [] [] arr = {{9,15},{18, 20, 40}}; Exception for (int i = 2; i >= 0 ; i--) D. Compilation Error { for (int j = 2; j >= 0; j--) { System.out.println(arr[i][j] + " " ); } } } } IT Specialist Java Review the following code: public class Main { What is the output of the program? public static void main (String [] A. 20 18 15 9 args) B. 40 15 20 9 18 { C. ArrayIndexOutOfBounds int [] [] arr = {{9,15},{18, 20, 40}}; Exception for (int i = 2; i >= 0 ; i--) D. Compilation Error { for (int j = 2; j >= 0; j--) { System.out.println(arr[i][j] + " " ); } } } } IT Specialist Java Complete the code class Rectangle { public class Main { private int width; public static void main(String[] args) { private int length; Rectangle rect = ____________(20, 40); public Rectangle(int width, int length) { System.out.printf("Width: %d%n", _____________); System.out.printf("Length: %d%n", _____________); this.width = width; this.length = length; } int areaNum = _____________; System.out.printf("Area is correct: %b%n", areaNum == 800); public int area() { } return width * length; } } public int getWidth() { return width; } public int getLength() { return length; } } IT Specialist Java Complete the code class Rectangle { public class Main { private int width; public static void main(String[] args) { private int length; Rectangle rect = new Rectangle(20, 40); public Rectangle(int width, int length) { System.out.printf("Width: %d%n", rect.getWidth()); System.out.printf("Length: %d%n", rect.getLength()); this.width = width; this.length = length; } int areaNum = rect.area(); System.out.printf("Area is correct: %b%n", areaNum == 800); public int area() { } return width * length; } } public int getWidth() { return width; } public int getLength() { return length; } } IT Specialist Java The Book.java program includes the following data members String title; String author; int year; int isbn; The default constructor assigns empty strings and zeros accordingly while the overloaded constructor take arguments in the order listed above. Complete the code where textbook will serve as the object for the program public static void main(String[] args) { ______ _______ = _____ ______; } IT Specialist Java The Book.java program includes the following data members String title; String author; int year; int isbn; The default constructor assigns empty strings and zeros accordingly while the overloaded constructor take arguments in the order listed above. Complete the code where textbook will serve as the object for the program public static void main(String[] args) { Book textbook = new Book(); } IT Specialist Java Evaluate the following code segment. public static void method1() { int x = 1; int y = 1; True False for (int i = 0; i < 10; i ++) { x += 1; } The first method causes a compilation error because the for (int i = 0; i < 10; i ++) { variable i is declared in two non y += 1; } nested blocks public static method2() { int i = 1; The second method causes int sum = 0 ; compilation error because the variable i is declared in two nested for (int i = 0 ; i < 10; i++) { blocks sum += i; } } IT Specialist Java Evaluate the following code segment. public static void method1() { int x = 1; int y = 1; True False for (int i = 0; i < 10; i ++) { x += 1; } The first method causes a compilation error because the for (int i = 0; i < 10; i ++) { variable i is declared in two non y += 1; } nested blocks public static method2() { int i = 1; The second method causes int sum = 0 ; compilation error because the variable i is declared in two nested for (int i = 0 ; i < 10; i++) { blocks sum += i; } } IT Specialist Java Evaluate the following class. public class Account{ True False protected int balance; public Account() { The Account has a single constructor balance = 0; Other classes can inherit the Account class } balance = amount; is equivalent this.balance = public Account (int amount) amount; { balance = amount; } } IT Specialist Java Evaluate the following class. public class Account{ True False protected int balance; public Account() { The Account has a single constructor balance = 0; Other classes can inherit the Account class } balance = amount; is equivalent this.balance = public Account (int amount) amount; { balance = amount; } } IT Specialist Java Evaluate the following code segment. Line numbers are included for reference only. 01 public static void main(String [] args) { 02 int anum = 55; 03 for (int cnt = 0; ct < 10; cnt++) { When cnt is 9, what is the value of anum after line 04 04 add(anum); runs? 05 } When cnt is 7, what is the value of anum after line 10 06 System.out.println(anum); runs? 07 } What is the value of cnt at line 6? 08 09 public static void add (int anum) { 10 anum++; 11 } IT Specialist Java Evaluate the following code segment. Line numbers are included for reference only. 01 public static void main(String [] args) { 02 int anum = 55; 03 for (int cnt = 0; ct < 10; cnt++) { When cnt is 9, what is the value of anum after line 04 04 add(anum); runs? 55 05 } When cnt is 7, what is the value of anum after line 10 06 System.out.println(anum); runs? 56 07 } What is the value of cnt at line 6? 10 08 09 public static void add (int anum) { 10 anum++; 11 } IT Specialist Java Evaluate the following code segment. Line numbers are included for reference only 01 byte value1 = 127 02 value1++; 03 System.out.println(value1); 04 System.out.println(1.0/3.0); 05 System.out.println(1.0f/3.0f); What is the output of line 03? What is the output of line 04? What is the output of line 05? IT Specialist Java Evaluate the following code segment. Line numbers are included for reference only 01 byte value1 = 127 02 value1++; 03 System.out.println(value1); 04 System.out.println(1.0/3.0); 05 System.out.println(1.0f/3.0f); What is the output of line 03? -128 What is the output of line 04? 0.3333333333333333 What is the output of line 05? 0.33333334 IT Specialist Java You need to always print every element in the two dimensional array/ Complete the code below for (int row = 0; row < intArray.length; row++) { for (int column = 0; _________________________) { System.out.println(intArray[row][column]); } } IT Specialist Java You need to always print every element in the two dimensional array/ Complete the code below for (int row = 0; row < intArray.length; row++) { for (int column = 0; column < intArray[row].length; column++) { System.out.println(intArray[row][column]); } } IT Specialist Java You have a Java class named Account. The constructor of the Account class accepts a String object. You need to create a class name SavingsAccount that inherits from the Account class. The constructor class performs the following tasks. Accept a String parameter named name. Pass a String value SavingsAccount to the constructor of the Account class Initialize the class member with value of the constructor parameter name. Complete the code below: public class SavingsAccount ____________ Account { String name; public SavingsAccount (String name) { ______ ("SavingsAccount")'; ______.name = name; } } IT Specialist Java You have a Java class named Account. The constructor of the Account class accepts a String object. You need to create a class name SavingsAccount that inherits from the Account class. The constructor class performs the following tasks. Accept a String parameter named name. Pass a String value SavingsAccount to the constructor of the Account class Initialize the class member with value of the constructor parameter name. Complete the code below: public class SavingsAccount ____________ Account { String name; public SavingsAccount (String name) { super ("SavingsAccount")'; this.name = name; } } IT Specialist Java You encounter error messages when you attempt to complete the program. Correct the code: class Pickle { boolean isPreserved = false; private boolean isCreated = false; void preserve() { isPreserved = true; } public static void main (String [] args) { Pickle pickle = new pickle(); iscreated = true; pickle.preserve; } } IT Specialist Java You encounter error messages when you attempt to complete the program. Correct the code: class Pickle { boolean isPreserved = false; private boolean isCreated = false; void preserve() { isPreserved = true; } public static void main (String [] args) { Pickle pickle = new Pickle(); pickle.isCreated = true; pickle.preserve(); } } IT Specialist Java Review the following class definition public class Box { protected short minBoxWidth; protected short maxBoxWidth; } Which class(es) can access the minBoxWidth and maxBoxWidth data members? A. Only the Box class B. Only classes in the same package and classes that inherit the Box class C. Only classes that do not inherit from the Box class D. All Classes IT Specialist Java Review the following class definition public class Box { protected short minBoxWidth; protected short maxBoxWidth; } Which class(es) can access the minBoxWidth and maxBoxWidth data members? A. Only the Box class B. Only classes in the same package and classes that inherit the Box class C. Only classes that do not inherit from the Box class D. All Classes IT Specialist Java You are creating a class named Phone that must meet the following requirements: Include a method named dialNumber that cannot be overridden by the derived classes. Only classes in the same package as the Phone class can call the dialNumber method Complete the code below: class Phone { ________ ____ void dialNumber(String phoneNumber) { System.out.println("Dialing number: " + phoneNumber); } } IT Specialist Java You are creating a class named Phone that must meet the following requirements: Include a method named dialNumber that cannot be overridden by the derived classes. Only classes in the same package as the Phone class can call the dialNumber method Complete the code below: class Phone { protected final void dialNumber(String phoneNumber) { System.out.println("Dialing number: " + phoneNumber); } } IT Specialist Java You are interviewing for a job as Java developer. You need to demonstrate your understanding of the main method. True False The main method parameter args is an array type of String A Java Application can accept only one argument from the command line The main method must be static because it is run without instantiating an instance of the class IT Specialist Java You are interviewing for a job as Java developer. You need to demonstrate your understanding of the main method. True False The main method parameter args is an array type of String A Java Application can accept only one argument from the command line The main method must be static because it is run without instantiating an instance of the class IT Specialist Java You initialize the following variables: int a = 5; double b = 3.5; int c = 33; float d = 0.5f; short e = 22; What are the answers for the following? a += 4% 2 + e; b /= 10 * 2; c %= e * 2 + 1; d *= 2 + 6 % 7; IT Specialist Java You initialize the following variables: int a = 5; double b = 3.5; int c = 33; float d = 0.5f; short e = 22; What are the answers for the following? a += 4% 2 + e; 27 b /= 10 * 2; 0.175 c %= e * 2 + 1; 33 d *= 2 + 6 % 7; 4.0 IT Specialist Java Evaluate the following code segment: What is the final value of x? A. 0 public class Main { B. 10 public static void main(String[] args) C. 20 { D. 50 int x = 50; E. 70 x += 100 % 5 + 10 * 2; F. 110 System.out.println(x); } } IT Specialist Java Evaluate the following code segment: What is the final value of x? A. 0 public class Main { B. 10 public static void main(String[] args) C. 20 { D. 50 int x = 50; E. 70 x += 100 % 5 + 10 * 2; F. 110 System.out.println(x); } } IT Specialist Java Review the following class definition class Logger { public void logError (String message) { } } What can invoke the logError method? A. Only code in all classes in the same package as Logger class B. Only the Logger class C. Only the Logger class and classes in the same package that inherit from it D. All classes in all packages IT Specialist Java Review the following class definition: class Logger { public void logError (String message) { } } What can invoke the logError method? A. Only code in all classes in the same package as Logger class B. Only the Logger class C. Only the Logger class and classes in the same package that inherit from it D. All classes in all packages IT Specialist Java The constructor method for the Rectangle class takes integer arguments named length and width. The length and width are declared in main and assigned values from user input. You need to create an instance of the Rectangle class named cert1. Complete the code below _______ _____ = _____ _______________; IT Specialist Java The constructor method for the Rectangle class takes integer arguments named length and width. The length and width are declared in main and assigned values from user input. You need to create an instance of the Rectangle class named cert1. Complete the code below Rectangle cert1 = new Rectangle(length, width); IT Specialist Java You are developing an application that reads and write files. The application must perform the following tasks: Display exceptions that are due to file handling errors. Display the stack information if any other exception occurs. Complete the code below: try { // add logic code } catch ( ____________ e1) { System.out.println (e1.___________) ; } catch (__________ e2) { System.out.println (e2.___________) ; } IT Specialist Java You are developing an application that reads and write files. The application must perform the following tasks: Display exceptions that are due to file handling errors. Display the stack information if any other exception occurs. Complete the code below: try { // add logic code } catch ( IOException e1) { System.out.println (e1.getMessage()) ; } catch (Exception e2) { System.out.println (e2. getMessage()) ; } IT Specialist Java You are writing a Java method named countdown. The method must perform the following tasks. Accept an int parameter named start Display all numbers from start to zero in decrements of one Complete the code public static void countdown (int start) { for (________ _____; ____) { System.out.println(i); } } IT Specialist Java You are writing a Java method named countdown. The method must perform the following tasks. Accept an int parameter named start Display all numbers from start to zero in decrements of one Complete the code public static void countdown(int start) { for (int i = start; i >= 0; --i) { System.out.println(i); } } IT Specialist Java You are interviewing for a job. The hiring manager asks you to create a simple console program. The program must perform the following tasks: Accept multiple arguments from the command line Write the arguments to the screen in the same order the users enters them on the command lin, Which three code segments should you use in sequence to develop the solution? Code segments 1. for (int i = 0 ; i < arguments.length; i++) { 2. for (int i = 0 ; i < Integer.parseInt(args; i++) { 3. System.out.println(arguments[i]) ; } } 4. public static void main (String arguments) { IT Specialist Java You are interviewing for a job. The hiring manager asks you to create a simple console program. The program must perform the following tasks: Accept multiple arguments from the command line Write the arguments to the screen in the same order the users enters them on the command lin, Which three code segments should you use in sequence to develop the solution? Code segments public static void main(String[] arguments) { 1. for (int i = 0 ; i < arguments.length; i++) { for (int i = 0; i < arguments.length; i++) { 2. for (int i = 0 ; i < Integer.parseInt(args; i++) { System.out.println(arguments[i]); 3. System.out.println(arguments[i]) ; } } } 4. public static void main (String arguments) { } IT Specialist Java Evaluate the following code segment. Line numbers are included for reference only. 01 public static void main (String [] args) { 02 double pi = Math.PI; //3.141593 03 System.out.format("Pi is %.3f%n", pi); 04 System.out.format("Pi is %.0f%n", pi); 05 System.out.format("Pi is %.09f%n", pi); 06 } What is the output in line 03? What is the output in line 04? What is the output in line 05? IT Specialist Java Evaluate the following code segment. Line numbers are included for reference only. 01 public static void main (String [] args) { 02 double pi = Math.PI; //3.141593 03 System.out.format("Pi is %.3f%n", pi); 04 System.out.format("Pi is %.0f%n", pi); 05 System.out.format("Pi is %.09f%n", pi); 06 } What is the output in line 03? 3.142 What is the output in line 04? 3 What is the output in line 05? 3.141592654 IT Specialist Java The Movie class includes a method isInMovie that is accessible only from within the class. The isInMovie method accepts the name of an actor to compare against a list of actors: Complete the code: ______ _______ isInMovie(_________) { for (int i = 0; i < numActors; i++) { if (actors[i].equals(actor)) { __________; } } __________; } IT Specialist Java The Movie class includes a method isInMovie that is accessible only from within the class. The isInMovie method accepts the name of an actor to compare against a list of actors: Complete the code: private boolean isInMovie(String actor) { for (int i = 0; i < numActors; i++) { if (actors[i].equals(actor)) { return true; } } return false; } IT Specialist Java You have a Java class named InsurancePolicy. You need to need to define a constant data member named RATE. The data member must be accessible by any class without instantiating the InsurancePolicy class. Complete the code below public class InsurancePolicy { ____ _____ _____ double RATE = 0.0642; } IT Specialist Java You have a Java class named InsurancePolicy. You need to need to define a constant data member named RATE. The data member must be accessible by any class without instantiating the InsurancePolicy class. Complete the code below public class InsurancePolicy { public static final double RATE = 0.0642; } IT Specialist Java You need to create an int array named numbers that is initialized with num1, num2, and num3 You have the following code: int num1 = 10; int num2 = 20; int num3 = 30; IT Specialist Java You need to create an int array named numbers that is initialized with num1, num2, and num3 You have the following code: int num1 = 10; int num2 = 20; int num3 = 30; int[] numbers = {num1, num2, num3}; IT Specialist Java Evaluate the following code segment. Line numbers are included for reference only. 01 String s1 = "Hello World"; 02 String s2 = "Hello World"; 03 String s3 = s2; 04 05 True or False True False s1 and s2 refer to the same object in memory s2 and s3 refer to the same object in memory A different string can be assigned to s1 on line 04 A different string can be assigned to s2 on line 05 IT Specialist Java Evaluate the following code segment. Line numbers are included for reference only. 01 String s1 = "Hello World"; 02 String s2 = "Hello World"; 03 String s3 = s2; 04 05 True or False True False s1 and s2 refer to the same object in memory s2 and s3 refer to the same object in memory A different string can be assigned to s1 on line 04 A different string can be assigned to s2 on line 05 IT Specialist Java The following Java method calculates scholarship award amounts based on grade point average (gpa). static double calculateAward (double gpa, int satScore, int actScore) { double award = 0; if (gpa >= 3.7 && (satScore >= 1200 || actScore >= 26)) { award = 30000; } else if (gpa >= 3.0 || satScore >= 1200 || actScore >= 26) { award = 15000; } What is the return value of calculateAward(3.2, 1100, 28) ? return award; What is the return value of calculateAward(2.7, 1500, 30) ? } What is the return value of calculateAward(3.7, 1300, 23) ? IT Specialist Java The following Java method calculates scholarship award amounts based on grade point average (gpa). static double calculateAward (double gpa, int satScore, int actScore) { double award = 0; if (gpa >= 3.7 && (satScore >= 1200 || actScore >= 26)) { award = 30000; } else if (gpa >= 3.0 || satScore >= 1200 || actScore >= 26) { award = 15000; } What is the return value of calculateAward(3.2, 1100, 28) ? 15000 return award; What is the return value of calculateAward(2.7, 1500, 30) ? 15000 } What is the return value of calculateAward(3.7, 1300, 23) ? 30000 IT Specialist Java Evaluate the following Java program. Line numbers are included for reference only. 01 public static void main (String [] args) 02 { 03 int x = 5; 04 int y = 7; 05 String value1 = "x + y = " + x + y; 06 System.out.println(value1); 07 String value2 = "x + y = " + (x + y); 08 System.out.println(value2); 09 What is the output of line 06? What is the output of line 08? IT Specialist Java Evaluate the following Java program. Line numbers are included for reference only. 01 public static void main (String [] args) 02 { 03 int x = 5; 04 int y = 7; 05 String value1 = "x + y = " + x + y; 06 System.out.println(value1); 07 String value2 = "x + y = " + (x + y); 08 System.out.println(value2); 09 What is the output of line 06? 57 What is the output of line 08? 12 IT Specialist Java You are writing a Java console program that accepts command-line arguments. The program must display each command-line argument on a separate line. Complete the code: public class Main { public static void main(String[] args) { ___ (String arg _ args) { System.out.println(___); } } } IT Specialist Java You are writing a Java console program that accepts command-line arguments. The program must display each command-line argument on a separate line. Complete the code: public class Main { public static void main(String[] args) { for (String arg : args) { System.out.println(arg); } } } IT Specialist Java You are creating a Java class to implement an Integer stack based on an ArrayList. You need to implement the following two methods: The pop method removes an Integer from the beginning of the ArrayList and returns the removed Integer. The push method adds an Integer to the beginning of the ArrayList public static Integer pop(ArrayList stack) { int index = ______________ return _______________ } public static void push(ArrayList stack, Integer item) { int index = _____________ ________________ } IT Specialist Java You are creating a Java class to implement an Integer stack based on an ArrayList. You need to implement the following two methods: The pop method removes an Integer from the beginning of the ArrayList and returns the removed Integer. The push method adds an Integer to the beginning of the ArrayList public static Integer pop(ArrayList stack) { int index = stack.size() - 1; return stack.remove(index); } public static void push(ArrayList stack, Integer item) { int index = stack.size(); stack.add(index, item); } IT Specialist Java A company hires you to write a Java program to manage credit account openings. To open an account must meet one the following requirements Be over 65 years old and have a minimum annual income of 10,000 Be at least 21 and have an annual income greater than 25,000 Complete the given code segment below to satisfy the given conditions: if ((age ____ 65 ____ income ______ 10000) || (age ____ 21 ____ income ______)) { System.out.println ("Approved"); } else { System.out.println ("Declined"); } IT Specialist Java A company hires you to write a Java program to manage credit account openings. To open an account must meet one the following requirements Be over 65 years old and have a minimum annual income of 10,000 Be at least 21 and have an annual income greater than 25,000 Complete the given code segment below to satisfy the given conditions: if ((age > 65 && income >= 10000) || (age >= 21 && income > 25000)) { System.out.println("Approved"); } else { System.out.println("Declined"); } IT Specialist Java What happens when the following code segment runs? double dNum = 2.667; int iNum = 0; iNum = (int)dNum; A. iNum has a value of 0 B. iNum has a value of 2 C. iNum has a value of 3 D. An exception is thrown IT Specialist Java What happens when the following code segment runs? double dNum = 2.667; int iNum = 0; iNum = (int)dNum; A. iNum has a value of 0 B. iNum has a value of 2 C. iNum has a value of 3 D. An exception is thrown IT Specialist Java You need to create an if statement that evaluates to true when both of the following conditions are met: sum is greater than or equal to num cnt is smaller than num if (sum ___ num ___ cnt ___ num) { // Your code here } IT Specialist Java You need to create an if statement that evaluates to true when both of the following conditions are met: sum is greater than or equal to num cnt is smaller than num if (sum >= num && cnt < num) { // Your code here } IT Specialist Java Which two code segments show the correct syntax for a multi-line comment (Choose 2) A. // B. // This is a multi- line comment */ D. IT Specialist Java Which two code segments show the correct syntax for a multi-line comment (Choose 2) A. // B. // This is a multi- line comment */ D. IT Specialist Java You need to determine what happens when the following code runs. Line numbers are included for reference only. 01 chat data1 = 65; 02 System.out.println(data1); Answer the following questions 03 What happens when lines 1 and 2 are run? What happens when lines 4 and 5 are run? 04 long data2 = 65; What happens when lines 7 and 8 are run? 05 System.out.println(data2); What happens when lines 10 and 11 are run? 06 07 float data3 = new Float("-65.0"); 08 System.out.println(data3); 09 10 short data = new Short("65.0"); 11 System.out.println(data4); IT Specialist Java You need to determine what happens when the following code runs. Line numbers are included for reference only. 01 chat data1 = 65; 02 System.out.println(data1); Answer the following questions 03 What happens when lines 1 and 2 are run? A What happens when lines 4 and 5 are run? 65 04 long data2 = 65; What happens when lines 7 and 8 are run? -65.0 05 System.out.println(data2); What happens when lines 10 and 11 are run? 65 06 07 float data3 = new Float("-65.0"); 08 System.out.println(data3); 09 10 short data = new Short("65.0"); 11 System.out.println(data4); IT Specialist Java Which code segment maintains the original array element when exiting the loop? A. int count = 0; C. for (Integer i: intArray) while (count < intArray.length) { { i *= 2; intArray[count] *= 2; } count++; } B. int count = 0; D. for (int i = 0; i