Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Java Section One (60 2 # 120 marks) 1.11 . I Multiple-Choice Questions (Select one answer out of all choices). 1. Which one of the

Java
image text in transcribed
Section One (60 2 # 120 marks) 1.11 . I Multiple-Choice Questions (Select one answer out of all choices). 1. Which one of the following statements is a valid initialization of an array named sonearray of ten elements? Answer: Vin 1OY (a) int01 somearray 1 0, 1, 2, 3, 4, 5, 6, 7, 8,9 (b) int sonearray D 0, 1, 2,3, 4, B, 6, 7, 8. 9, 10 )d (e) int[10] somearray- [0, 1, 2, 3, 4. 5, 6, 7, 8, 9 ) (d) ist sosearray [10]-(0, 1, 2, 3, 4, 5, 6, 7. 8, 9 ) Code fragment below is for Question 2 to Question 6. public class MyString public static void main(String args) String a1-eu String("Hello World!): String s2 new String("Hello World!") String s3 "Hello World!" String s4 -"Hello World!" System , out . printla(s1..#2) ; //1ise a Systen.out printin (83 4): I/ line b Syatom.oat println(s1.equals (s2)): / 1ise c Syatem.out,pristin(e1.equalsCa3)):// line d 2. What would be the output of line a? Answer: 3. What would be the output of line b? Answer: 1 4. What would be the output of line e? Answer: I 1 5. What would be the output of line d? Answer: [ 6. How many String objects created? Answer: [ 7. A Java program can handle an exception in several different ways. Which of the folowing is (a) true (b) false (a) true (b) false (a) true (b) false (a) true(b) false (a) 1 (b) 2 (c)3 (e) none of a or b (c) none of a or b (c) none of a or b (c) none of a or b (d) 4 way that a Java program could handle an exceptin? Answer: (a) handle the exception where it arose using try and catch statements (b) propagate the exception to another method where it can be handlesd (c) throw the exception to a pre-defined Exception class to be handled (d) all of the above are ways that a Java program could handle an exception 8. An exception can produce a all stack trace" wbich lists Answer: 1 (a) the active methods in the order that they were invoked (b) the active methods in the opposite order that they were invoked (c) the values of all instance data of the object where the exception was raised (d) the name of the exception thrown

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions