Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 8 pages
Exam (elaborations)

ITCS 1213 UNCC FINAL EXAM QUESTIONS AND ANSWERS

Document preview thumbnail
Preview 2 out of 8 pages

ITCS 1213 UNCC FINAL EXAM QUESTIONS AND ANSWERS /Is it possible to create an array in Java where the first row has 5 elements, the second row has 6 elements and the third row has 2 elements? - Answer-yes /.create a for loop to execute: Is it possible to create an array in Java where the first row has 5 elements, the second row has 6 elements and the third row has 2 elements? - Answer-double [] [] salaries = new double [NUM_STORES][]; array[0] = new double [5]; array[1] = new double [6]; array[2] = new double [2]; /.Write the statement to print the number of elements in a one-dimensional array. - Answer-for(i =0; ih -1; i++) { Sln(array[i]); } /.What does Java initialize the elements of an array of references to? - Answer-null /.What does Java initialize an array of ints to? - Answer-0 /.Is an array an object? - Answer-Yes /.int [ ] numbers = new int[16] how many objects were created? - Answer-1, new was used once /.Student [ ] roster = new Student[25] - how many objects were created? - Answer-1, new was used once /.Write the command to compile a source code file named B - Answer-javac B /.Write the command to run a class file named B - Answer-java Book /.Where does the execution of a Java project begin? - Answer-public static void main(String [] args) /.How many public classes can a Java class file contain? - Answer-1 /.Can you declare fields of a class inside a method? - Answer-No /.What does private access for a field mean? - Answer-Only the current class will have access to the field or method. /.What does public access for a field mean? - Answer-Any class can refer to the field or call the method. /.What does protected access for a field mean? - Answer-Only the current class and sub classes (and sometimes also same-package classes) of this class will have access to the field or method. /.What happens if you do not specify the access for a field? - Answer-It will set the access to package /.Can a sub-class also be a super-class? - Answer-Yes, Java allows this /.What is an abstract method? - Answer-It is a method that is declared, but contains no implementation /.What is an abstract class? - Answer-Is a class that is declared abstract —it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be sub classed. /.Does a super class have to be abstract? - Answer-No /.How many classes can a class directly inherit from? - Answer-1 /.How many interfaces can a class implement? - Answer-Multiple or unlimited /.What can a Java interface contain? - Answer-Consists of modifiers, the keyword interface, the interface name, a comma-separated list of parent interfaces (if any), and the interface body /.Can an interface be instantiated? - Answer-You can never instantiate an interface in java. /.Does the is-a relationship apply to classes that implement an interface? - Answer-No /.What is the difference between overloading a method and overriding a method? - Answer-Overloading: is the ability to create multiple methods of the same name with different implementations. Overriding: is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes. /.What class does every class indirectly inherit from? - Answer-Object class

Content preview

ITCS 1213 UNCC FINAL EXAM
QUESTIONS AND ANSWERS
/Is it possible to create an array in Java where the first row has 5 elements, the second
row has 6 elements and the third row has 2 elements? - Answer-yes

/.create a for loop to execute: Is it possible to create an array in Java where the first row
has 5 elements, the second row has 6 elements and the third row has 2 elements? -
Answer-double [] [] salaries = new double [NUM_STORES][];
array[0] = new double [5];
array[1] = new double [6];
array[2] = new double [2];

/.Write the statement to print the number of elements in a one-dimensional array. -
Answer-for(i =0; i<array.length -1; i++)
{
System.out.println(array[i]);
}

/.What does Java initialize the elements of an array of references to? - Answer-null

/.What does Java initialize an array of ints to? - Answer-0

/.Is an array an object? - Answer-Yes

/.int [ ] numbers = new int[16] how many objects were created? - Answer-1, new was
used once

/.Student [ ] roster = new Student[25] <- how many objects were created? - Answer-1,
new was used once

/.Write the command to compile a source code file named Book.java - Answer-javac
Book.java

/.Write the command to run a class file named Book.class - Answer-java Book

/.Where does the execution of a Java project begin? - Answer-public static void
main(String [] args)

/.How many public classes can a Java class file contain? - Answer-1

/.Can you declare fields of a class inside a method? - Answer-No

, /.What does private access for a field mean? - Answer-Only the current class will have
access to the field or method.

/.What does public access for a field mean? - Answer-Any class can refer to the field or
call the method.

/.What does protected access for a field mean? - Answer-Only the current class and sub
classes (and sometimes also same-package classes) of this class will have access to
the field or method.

/.What happens if you do not specify the access for a field? - Answer-It will set the
access to package

/.Can a sub-class also be a super-class? - Answer-Yes, Java allows this

/.What is an abstract method? - Answer-It is a method that is declared, but contains no
implementation

/.What is an abstract class? - Answer-Is a class that is declared abstract —it may or
may not include abstract methods. Abstract classes cannot be instantiated, but they can
be sub classed.

/.Does a super class have to be abstract? - Answer-No

/.How many classes can a class directly inherit from? - Answer-1

/.How many interfaces can a class implement? - Answer-Multiple or unlimited

/.What can a Java interface contain? - Answer-Consists of modifiers, the keyword
interface, the interface name, a comma-separated list of parent interfaces (if any), and
the interface body

/.Can an interface be instantiated? - Answer-You can never instantiate an interface in
java.

/.Does the is-a relationship apply to classes that implement an interface? - Answer-No

/.What is the difference between overloading a method and overriding a method? -
Answer-Overloading: is the ability to create multiple methods of the same name with
different implementations.

Overriding: is a language feature that allows a subclass or child class to provide a
specific implementation of a method that is already provided by one of its superclasses
or parent classes.

/.What class does every class indirectly inherit from? - Answer-Object class

Document information

Uploaded on
April 2, 2025
Number of pages
8
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Brainariam
3.3
(27)
Sold
151
Followers
7
Items
8384
Last sold
1 week ago


Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions