JAVA Questions In the following means In the exam could you
JAVA Questions!
In the following, means \"...\" In the exam, could you tell me...\" Do you understand simple UML diagrams? ...what a simple UML diagram showing object inheritance (is-a) means? ...what a simple UML diagram showing object containment (has-a) means? Do you understand inheritance? ...the output of code that uses simple inheritance? ...the output of code that uses method overriding? ...the output of code that uses runtime polymorphism? ...the syntax for creating inherited classes? Do you understand exceptions? ...the output of code that uses try/catch blocks if an exception is, or is not, thrown? ...the output of code that uses multiple catch blocks for different exception types? ...the output of code that uses try/catch/finally blocks? ...the syntax for creating and throwing an exception? ...the difference between checked and unchecked exceptions? Do you understand ArrayLists? ...the syntax for creating an ArrayList? ...how we can store primitive types in an ArrayList? ...the output of code that manipulates an ArrayList to add and remove elements? Do you understand interfaces? ...the syntax for implementing an interface? ...what we must do when implementing an interface? ...why we might choose to use an interface instead of inheritance in our code? Do you understand abstract classes? ...the syntax for specifying an abstract class? ...what we cannot do with an abstract class? ...why we might choose to use an abstract class? Do you understand generics? ...the syntax for using a generic class? (e.g. an ArrayList) ...why we might choose to create our own generic class? Do you understand recursion? ...the bug in some code that will cause infinite recursion? ...the output of recursive code that uses a single recursive call? ...the output of recursive code that uses two recursive calls? ...how to fill in the blanks in a simple recursive algorithm? ...how to convert a simple iterative algorithm into a recursive one? Do you understand basic file I/O? ...the output of code that uses a simple Scanner object with has NextLine() and nextLine() calls to process a text fileSolution
The uml diagram showing object iheritance represents the parent class from which all other classes are inherited.Ex.An apple is red here red is a color(parent class) and apple is another class inheriting color class.
Uml with object containement means an object can be consist of one or more objects.
-->program with output for simple inheritence:
class Parent
{
public void whoareyou()
{
System.out.println(\"I am Parent method\");
}
}
public class Child extends Parent {
public void another()
{
System.out.println(\"Child method\");
}
public static void main(String[] args)
{
Child cobj = new Child();
cobj.another(); //Child class method
cobj.whoareyou(); // Parent class method
}
}
*********output************
Child method
Parent method
