CS5318 Homework #1 Solution

$30.00

Category:

Description

  1. Fill the following blanks:
  2. When two different methods have the same name in a class, this is an example of ………………..
  3. A (An) …………….. is like a class except that it contains only instance methods, no instance variables.
  4. Instance variables and instance methods that are declared ……….. or …………….

are inherited by the subclasses.

  1. A method that is invoked when an object is created is known as a ……………
  2. Constants should be declared ………...
  3. If x is an object of class A and y is an object of class B that is a subclass of A, after the assignment x = y, why is x.m() illegal when m is a method of B but not A?

 

  1. Write a Java program segment that prints the index of the first all-zero row of an nXn integer matrix M. The code should access each element of the matrix at most once and should not access rows beyond the first all-zero row and columns within any row beyond the first non-zero element. It should have no variables except the matrix M and two loop indices row and column.

 

  1. Java has the >>> operator, but C does not. What does the >>> do? Why is it needed in

Java but not in C?

 

  1. Why is it not possible to create an object of an abstract class? Does this mean that variables of abstract class types cannot be declared? Explain.

 


error: Content is protected !!