• Tidak ada hasil yang ditemukan

CSC 113 TUTORIAL

N/A
N/A
Protected

Academic year: 2025

Membagikan "CSC 113 TUTORIAL"

Copied!
13
0
0

Teks penuh

(1)

QUIZ I

CSC 113 TUTORIAL

(2)

• Take out a paper.

• Write your name and date.

• Type the question number next to the answer i.e Question 1 ) A

• Each question will be shown on the board a max of 3 mins, act fast.

Good luck

INSTRUCTIONS

(3)

1. An object is an instance of a __________.

2. The keyword __________ is required to declare a class.

3. ________ is used to create an object.

FILL IN THE SPACE

(4)

4) Given the declaration

Student [ ] x = new Student[10];

which of the following statement is most accurate?

A. x contains an array of ten int values.

B. x contains an array of ten objects of the Student type.

C. x contains a reference to an array and each element in the array can hold a reference to a Student object.

D. x contains a reference to an array and each element in the array can hold a Student object.

CHOOSE ONE OF THE FOLLOWING

(5)

5) When invoking a method with an object argument, ___________ is passed.

A. the contents of the object B. a copy of the object

C. the reference of the object

D. the object is copied, then the reference of the copied object

CHOOSE ONE OF THE FOLLOWING

(6)

6) Variables that are shared by every instances of a class are __________.

A. public variables B. private variables C. instance variables D. class variables

CHOOSE ONE OF THE FOLLOWING

(7)

7) Which of the following statements are true?

A. A default constructor is provided automatically if no constructors are explicitly declared in the class.

B. At least one constructor must always be defined explicitly.

C. Every class has a default constructor.

D. The default constructor is a no-arg constructor.

CHOOSE FROM THE FOLLOWING

(8)

8) Which of the following is incorrect?

A. int[] a = new int[2];

B. int[] a = new int(2);

C. int a = new int[2];

D. int a() = new int[2];

CHOOSE FROM THE FOLLOWING

(9)

9) Which of the following statements are true?

A. A default constructor is provided automatically if no constructors are explicitly declared in the class.

B. At least one constructor must always be defined explicitly.

C. Every class has a default constructor.

D. The default constructor is a no-arg constructor.

CHOOSE FROM THE FOLLOWING

(10)

10) Which of the following statements are true?

A. A subclass is a subset of a superclass.

B. A subclass is usually extended to contain more functions and more detailed information than its superclass.

C. "class A extends B" means A is a subclass of B.

D. "class A extends B" means B is a subclass of A.

CHOOSE FROM THE FOLLOWING

(11)

public class Student { String name;

public Student(String name) { this.name = name; }

void print( ) {

System.out.println(name); } }

public class Test {

public static void main(String[] args) { Student s = new Student( );

s.print( );

} } 11)

A. The program has a compilation error because class Student does not have getName( ).

B. The program has a compilation error because class Student does not have a default constructor.

C. The program compiles and runs fine and prints nothing.

D. The program would compile and run if you change Student s = new Student( ) to Student s = new Student("5").

CHOOSE FROM THE FOLLOWING

(12)

public class Parent { int id = 1;

public void print() { System.out.println(id);

} }

public class Child extends Parent { int id = 2;

}

public class Test1 {

public static void main(String[]

args) {

Child c = new Child();

c.print( );

12) What is the output of the following code?

A. A. 0 B. 1 C. 2 D. Error

CHOOSE FROM THE FOLLOWING

(13)

13) Write a class with a main method that shows a menu and ask the user to enter a choice to do the following:

1. Print your Name.

2. Show your Student ID.

3. Exit.

Don’t forget to use default.

WRITE THE FOLLOWING PROGRAM

Referensi

Dokumen terkait

The ChatRoom.java file creates the user interface that allows end users to enter the chat room by specifying the name of the chat room for the Connector application.. Listing 2-6

To create a class, computer server need to enter the class name and then system will send all class list (class names and the IP server) names to all existing clients in the current

Enter the name of the rollover image file in the Rollover Image field or click the Browse button to select an image from your files.. The rollover image appears on the page when

SECTION 3 – continued Question 7 Your Year 12 Indonesian class wants to undertake an intensive language course in Indonesia.. Write a formal letter persuading your school principal

Applicant Name: ___________________________ Personal Essay: In the space below, please write a short essay in English about the following: yourself and your family; your educational

Mobile number of the head of your department : Part 8: Impact area of your research work a Write name of industries /area of knowledge your research result will impact on i ii Part

Sample: Enter two lowercase letters: ba ab Enter two lowercase letters: zt tz Task2: Write an assembly program to take an uppercase letter between A-U as input from user and display

“Brand extensions, the use of a brand name established in one product class to enter another product class, have been the core of strategic-­‐growth for a variety of firms,