These are the core tenets of OOP.
What are, Inheritance, Encapsulation, Polymorphism, and Abstraction.
for (int i = 12; i > 0; i--) {
System.out.print(i + ", ");
} This for loop will print out _______________.
What is 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
int n = 1000;
System.out.println("Hey - your input is: " + n);
System.out.println("Hmm.. I'm doing more stuff with: " + n);
System.out.println("And more: " + n);
The Big-O complexity for this code is ____________.
What is O(1)
A finally block executed when an exception is thrown from a try block that does not have a catch block.
When is a finally block is executed?
JDK stands for ___________________.
What is Java Development Kit?
Overloading is related to compile time (or static) polymorphism. This feature allows different methods to have same name, but different signatures, especially number of input parameters and type of input paramaters.
What is Overloading.
This for loop will execute ________ times: for(int i = 0;;i++){}
What is an infinite loop. Or infinitely counting upwards.
This data structure implements the LIFO paradigm.
What is Stack?
This is the super class for all types of errors and exceptions in java.
What is java.lang.Throwable.
JVM stands for ______________.
What is Java Virtual Machine?
Static methods can be overloaded.
What is yes.
How many times will this loop iterate:
for (int i = 0; i >=65; i++) {}
What is none?
ArrayList, LinkedList, and Vector are all implementations of the List interface. This is most efficient for adding and removing elements from the list?
What is LinkedList.
This method is used to print the detailed information about the exception that occurred.
What is printStackTrace();
Methods that can access an Encapsulated field.
What is a getter/setter?
We can override static methods.
What is no. Static methods cannot be overridden because method overriding only occurs in the context of dynamic (i.e. runtime) lookup of methods. Static methods (by their name) are looked up statically (i.e. at compile-time).
public class A {
public static void main(String[] args)
{
if (true)
break;
}
Returns ________________.What is an error. break can only be used in a loop or a switch.
Java enums are more powerful than integer constants.
What are Enums are essentially final classes with a fixed number of instances. They can implement interfaces but cannot extend another class?
The output is:
public class Test
{
public static void main(String[] args)
{
try
{
System.out.printf("1");
int data = 5 / 0;
}
catch(ArithmeticException e)
{
System.out.printf("2");
System.exit(0);
}
finally
{
System.out.printf("3");
}
System.out.printf("4");
}
}
What is 12?
This refers to changing an entity of one datatype into another.
What is Typecasting.
This keyword is used to call immediate parent constructor in a class.
What is super();
public class A {
public static void main(String[] args)
{
int $_ = 5;
}
} This outputs _____________.
What is nothing? Java variables can start with any character.
In binary trees, this is the algorithm for an Inorder tree traversal.
What is:
1. Traverse the left subtree, i.e., call Inorder(left-subtree)
2. Visit the root.
3. Traverse the right subtree, i.e., call Inorder(right-subtree)
List<Integer> integers = Arrays.asList(3, 9, 7, 0, 10, 20);
integers.forEach(i -> {
if (i == 0) {
throw new IllegalArgumentException("Zero not allowed");
}
System.out.println(Math.PI / i);
});
When using a standard functional interface already provided by Java, you can only throw unchecked exceptions because standard functional interfaces do not have a “throws” clause in its method signatures?
This is a value that denotes the location of an object in memory (Rectangle box = new Rectangle --> box is the reference to the object)
What is a Reference.