Week4Assignment

Week4Assignment - Q1 What Line is the problem with the...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Q1 1. public class Student{ 2. private String name; 3. public String id; 4. public Student(String studentName, String studentId){ 5. name = studentName; 6. id = studentId; 7. } 8. public String getId(){ 9. return id; 10. } 11. } 12. public class professor{ 13. public static void main(String[] args){ 14. Student s = new Student(“John Doe”, “515”); 15. System.out.println(“Name: “ + s.name + “ID: “ + s.getId()); 16. } 17. } What Line is the problem with the following code on? A: Line 4 B: Line 9 C: Line 14 D: Line 15
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Q2 void function1(String t) { t = new String(“World”); } void function2(String t) { t = t + “World”; } void function3(StringBuffer t) { t.append(“World”); } What Function affects the original string passed into these functions? A: Function 1 B: Function 2 C: Function 3 D: All of these Functions E: None of these Functions
Background image of page 2
Q3 1. public class Student{ 2. private String name; 3. public String id; 4. public Student getNewStudent(String name, String id){
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/19/2012 for the course CS 180 taught by Professor Staff during the Spring '08 term at Purdue.

Page1 / 5

Week4Assignment - Q1 What Line is the problem with the...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online