Midterm questions Flashcards
Normally the instance variables in a java class are given which access qualifier?
private
A data item that can only be used within in java method is called?
local variable
suppose that java class A inherits from Class B, and suppose a1 and b1 refer to objects of class A and B. Which one of the options is true?
a1 could be assigned to b1, but b1 could not be assigned to a1
What is the name of java mechanism for passing parameters to methods?
call by value
if the expression super.super.doit() appear in a method, this expression will cause a
Syntax error (“cause super is a key word”)
What is the best description for overriding method?
Method in a base class and derived class have the same signature and the return type
What is the best description for overloading method?
Two method in a class have the same name, but different numbers of parameters
All objects of the same class will have the ___ data members and the ___ methods
same, same
Java will automatically define a constructer for a class
If the programmer does not define any constructers for the class
Which two of the following statements about array are FALSE?
- You can get the size of the array by using its length () method
- The size of an array can be changed after it has been created
The acronym of JVM is ?
Java Virtual Machine
The five exceptions related java keyword are
- try
- catch
- throw
- throws
- finally
The number of simple numerical (int and floating point) data types in java is _____
6
- Int
- floating point
- long
- short
- double
- byte
The name of java data type whose maximum is 32767 is
short
Suppose you have the source code for a class called SomeClass in an named file and you have a command window open on the directory containing that file. Assume the file also contains the appropriate comments. Give the simplest command that will create HTML documentation for just this class and place that in a subdirectory called mydoes in the current directory:
javadoc -d/ directory / SomeClass
Suppose you are preparing an executable jar file, in which the driver class is called someClass. Then your manifest file contains the line ____
Main-Class: SomeClass
In java, every class is descendant of the class named:
Object as a super class
The name of the only java package that you can use without explicitly import it, or any of the classes contained in it , is _____
java.lang.Object
The output of the substing System.out.println(“123456”.substring(2,4)); is
34
In java a ____ method is one which doesn’t have a body and it is meant to be overridden in every derived class
abstract methods