Java Programming homework part 2

profileBell0216
fall2013_assignment_5.doc

North Carolina A&T State University

ITT 240-01- Java

Fall - 2013

Assignment 5

· Due on Monday November 20th.

· Soft copy to be sent by e-mail or posted to Bb.

· Source file(s) is/are required

· Output screen snapshots also are required

· Word document explains the answers for each part.

· Please write your name and student ID at the top of the word document

EX 1:

Which of the following class definitions defines a legal abstract class?

image1.png

EX 2:

Which of the following is a correct interface?

image2.png

EX 3:

Show the printout of the following code:

java.util.Date date = new java.util.Date();

java.util.Date date1 = (java.util.Date)(date.clone());

System.out.println(date == date1);

System.out.println(date.equals(date1));

EX 4:

Are the following statements correct?

Integer i = new Integer("23");

Integer i = new Integer(23);

Integer i = Integer.valueOf("23");

Integer i = Integer.parseInt("23", 8);

Double d = new Double();

Double d = Double.valueOf("23.45");

int i = (Integer.valueOf("23")).intValue();

double d = (Double.valueOf("23.4")).doubleValue();

int i = (Double.valueOf("23.4")).intValue();

String s = (Double.valueOf("23.4")).toString();

EX 5:

What is wrong in the following code?

public class Test {

public static void main(String[] args) {

Number x = new Integer(3);

System.out.println(x.intValue());

System.out.println((Integer)x.compareTo(new Integer(4)));

}

}

Reading Exercise

Read chapter 10. Propose 6 – 12 keywords. Compose 2 – 3 sentences to describe each chapter in a concise, comprehensive, and unambiguous manner.

PAGE

Dr. Naser El-Bathy Page 3