<< Chapter < Page Chapter >> Page >
Part of a self-assessment test designed to help you determine how much you know about comparing objects, packages, import directives, and some common exceptions in Java.

Table of contents

Preface

This module is part of a self-assessment test designed to help you determine how much you know about object-orientedprogramming using Java.

The test consists of a series of questions with answers and explanations of the answers.

The questions and the answers are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back.

I recommend that you open another copy of this document in a separate browser window and use the links to under Listings to easily find and view the listings while you are reading about them.

Questions

Question 1 .

What output is produced by the program shown in Listing 1 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. Joe Joe false
  • D. Joe Joe true
  • E. None of the above.
Listing 1 . Listing for Question 1.
public class Ap141{ public static void main(String args[]){new Worker().doIt(); }//end main()}//end class Ap141 class Worker{void doIt(){ char[]anArray = {'J','o','e'}; String Str1 = new String(anArray);String Str2 = new String(anArray); System.out.println(Str1 + " " + Str2 + " " + (Str1 == Str2));}//end doIt() }// end class Worker

Answer and Explanation

Question 2

What output is produced by the program shown in Listing 2 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. Joe Joe false
  • D. Joe Joe true
  • E. None of the above.
Listing 2 . Listing for Question 2.
public class Ap142{ public static void main(String args[]){new Worker().doIt(); }//end main()}//end class Ap142 class Worker{void doIt(){ char[]anArray = {'J','o','e'}; String Str1 = new String(anArray);String Str2 = new String(anArray); System.out.println(Str1 + " " + Str2 + " " + Str1.equals(Str2));}//end doIt() }// end class Worker

Answer and Explanation

Question 3

What output is produced by the program shown in Listing 3 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. ABC DEF GHI
  • D. None of the above.
Listing 3 . Listing for Question 3.
public class Ap143{ public static void main(String args[]){new Worker().doIt(); }//end main()}//end class Ap143 class Worker{void doIt(){ java.util.ArrayList ref =new java.util.ArrayList(1); ref.add("ABC ");ref.add("DEF "); ref.add("GHI");System.out.println((String)ref.get(0) + (String)ref.get(1) +(String)ref.get(2)); }//end doIt()}// end class Worker

Answer and Explanation

Question 4

What output is produced by the program shown in Listing 4 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. ABC DEF GHI
  • D. None of the above.
Listing 4 . Listing for Question 4.
public class Ap144{ public static void main(String args[]){new Worker().doIt(); }//end main()}//end class Ap144 class Worker{void doIt(){ ArrayList ref =new ArrayList(1); ref.add("ABC ");ref.add("DEF "); ref.add("GHI");System.out.println((String)ref.get(0) + (String)ref.get(1) +(String)ref.get(2)); }//end doIt()}// end class Worker

Questions & Answers

Why is b in the answer
Dahsolar Reply
how do you work it out?
Brad Reply
answer
Ernest
heheheehe
Nitin
(Pcos∅+qsin∅)/(pcos∅-psin∅)
John Reply
how to do that?
Rosemary Reply
what is it about?
Amoah
how to answer the activity
Chabelita Reply
how to solve the activity
Chabelita
solve for X,,4^X-6(2^)-16=0
Alieu Reply
x4xminus 2
Lominate
sobhan Singh jina uniwarcity tignomatry ka long answers tile questions
harish Reply
t he silly nut company makes two mixtures of nuts: mixture a and mixture b. a pound of mixture a contains 12 oz of peanuts, 3 oz of almonds and 1 oz of cashews and sells for $4. a pound of mixture b contains 12 oz of peanuts, 2 oz of almonds and 2 oz of cashews and sells for $5. the company has 1080
ZAHRO Reply
If  , , are the roots of the equation 3 2 0, x px qx r     Find the value of 1  .
Swetha Reply
Parts of a pole were painted red, blue and yellow. 3/5 of the pole was red and 7/8 was painted blue. What part was painted yellow?
Patrick Reply
Parts of the pole was painted red, blue and yellow. 3 /5 of the pole was red and 7 /8 was painted blue. What part was painted yellow?
Patrick
how I can simplify algebraic expressions
Katleho Reply
Lairene and Mae are joking that their combined ages equal Sam’s age. If Lairene is twice Mae’s age and Sam is 69 yrs old, what are Lairene’s and Mae’s ages?
Mary Reply
23yrs
Yeboah
lairenea's age is 23yrs
ACKA
hy
Katleho
Ello everyone
Katleho
Laurene is 46 yrs and Mae is 23 is
Solomon
hey people
christopher
age does not matter
christopher
solve for X, 4^x-6(2*)-16=0
Alieu
prove`x^3-3x-2cosA=0 (-π<A<=π
Mayank Reply
create a lesson plan about this lesson
Rose Reply
Excusme but what are you wrot?
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?

Ask