Section 1

Preview this deck

What is method overrriding and method overloading?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (115)

Section 1

(50 cards)

What is method overrriding and method overloading?

Front

Method over riding is a sub class having the same method signature as they're super class but different implementation. Method over loading is a class having the same method name with different amount of parameters.

Back

Assuming a method contains code which may raise an exception, but not a Runtime Exception, what is the correct way for the method to indicate that it expects the caller to handle that exception?

Front

in the method signature you can throws exception

Back

What is the differences between String, String Builder, and String Buffer?

Front

Strings are immutable. String Builder and String Buffer are mutable. String Builder is not synchronized. String Buffer is synchronized.

Back

Why are strings immutable?

Front

Strings cannot change once they are created. This is because multiple references point to the same string in the string pool and if one reference changes the string, the other references would point to this changed string. Strings are immutable to conserve memory.

Back

Is java pass by value or pass by reference?

Front

Java is pass by value. A copy of the the callers parameters are passed.

Back

What is the difference between HashTable and HashMap?

Front

HashTable is synchronized. HashMap is not synchronized. HashTable does not allow null values. HashMap allows null values and the null key.

Back

How do you clone an object?

Front

Mark the class cloneable. Invoke the clone method. The clone method makes a shallow copy of the object which means it makes a copy of the reference.

Back

What are some Thread methods?

Front

start. sleep. yield. join. isAlive.

Back

How do you get the size of an array arr?

Front

arr.length;

Back

What is stored on the stack and what is stored on the heap?

Front

Stack allocates memory for methods, references, and primitives. It is used for static allocation. Heap allocates memory for objects and anything using the new call. It is used for dynamic allocation. Garbage collection is ran on the heap. Threads have their own stack.

Back

What is the difference between Statement and Prepared Statement?

Front

Both are interfaces of jdbc. A statement is used for single sql statements. A prepared Statement is used to execute a sql statement that will be used many times. A prepared Statement is used to prevent sql injection. a prepared Statement is used when you need to pass parameters to the query at run time.

Back

What is the difference between ArrayList and Vector?

Front

ArrayList is not synchronized. Vectors are synchronized and thread safe.

Back

What is the difference between == & .equals()

Front

"==" checks to see if two references point to the same instance of an object. equals() checks to see if two objects are equal, but they don't have to point to the same instance of the object.

Back

Does an unchecked exception have to be dealt with a try catch block?

Front

No. Unchecked exceptions are compile time exceptions.

Back

Are String and String Buffer mutable?

Front

No. Strings are immutable. String Buffer is mutable and synchronized.

Back

Can a sub class access private members of the super class?

Front

No. A sub class in a different package can access protected and public members of a super class.

Back

Does a try block need a catch block?

Front

No. a try block can have a catch and/or a finally block.

Back

What are transient variables

Front

Transient variables are variables that are not serializable.

Back

How can you create a thread?

Front

Extend the thread class and override the run method. Implement the Runnable interface and pass an instance to the thread constructor.

Back

Does a Set have to contain unique elements?

Front

Yes.

Back

How do you serialize an object?

Front

Use the Serializable marker interface on a class. Create an object of the class and persist it using the java.io.OutputStream class.

Back

What memory areas are allocated by the JVM?

Front

Stack Heap PC Register Class Loader Class Area Execution Engine

Back

What is polymorphism? Give an example.

Front

Polymorphism is the ability of inherited methods to change their behavior depending on what subclass they are in. Example: Cat and Dog inherit from Pet, but the method make Sound would be different in the sub classes.

Back

What are the different types of polymorphism.

Front

Method overloading and overriding. Method over loading is compile time. The compiler checks the number of parameters. Method over riding is run time. The overridden code in the method is ran.

Back

What are the implicit modifiers required for interface variables?

Front

static final static to make it global final to make it constant

Back

What is the difference between TreeSet and HashSet?

Front

HashSet is faster than TreeSet. HashSet has no ordering guarantees, but TreeSet does. HashSet has constant time operations. TreeSet has log time operations.

Back

What is encapsulation? Give an example

Front

Encapsulation is the binding of instance methods with a class. Access to the data and code is controlled by a barrier. Example: creating getters and setters for a class to restrict access to the instance variables.

Back

How can a final variable be initialized when its declared in a class?

Front

Initialized in line: final int MAX = 5; Initialized in each constructor Initialized in a non static block

Back

What are the differences between array and Array List?

Front

Arrays are static in size. Array Lists are dynamic. Arrays are multi dimensional. Array Lists are single dimensional. Both can store null and duplicate values.

Back

What is final, finalize(), and finally?

Front

final is a keyword that can be used on classes, methods, and variables. Final classes can't have subclasses. Final methods can't be overridden. Final variables can't be changed. finalize is a method used by the garbage collector before it collects non referenced objects. finally is part of a try catch block that runs regardless if an exception is caught.

Back

What is a stored procedure and how do you call it from a java class?

Front

A stored procedure is an executable block of code written in pl/sql. You call a stored procedure using the callableStatement interface of jdbc.

Back

What is the thread lifecycle?

Front

Thread lifecycle : Runnable Blocked Waiting Terminated

Back

Do you need to initialize an object to call a static method?

Front

No. You can call a static method by using class.staticMethod(). If you are in the class, you can just call staticMethod().

Back

What is the difference between an interface and an abstract class

Front

An interface only has abstract methods. An abstract class can have abstract classes and concrete methods. Every interface method must be overridden. There are functional and marker interfaces. Interfaces can extend multiple other interfaces. Since java 8, interfaces can have default methods that don't need to be overridden.

Back

Can you name some differences between Linked List and Array List?

Front

Searching is faster in Array Lists than Linked Lists. Deletion is faster in Linked Lists than Array Lists. Insertion is faster in Linked Lists than Array Lists.

Back

What is a marker interface?

Front

A marker interface has no methods. It is used to specify classes that should have additional functionality. Example: serializable, remote, cloneable

Back

What is inheritance? Give an example.

Front

Inheritance is the ability of sub classes to inherit functionality from they're super class. This promotes code reuse. Example: A boss implements the characteristics of an employee, but has more characteristics.

Back

What is the difference between static and final variables.

Front

Static variables are global and there is only a single instance of it. Final variables cannot be changed.

Back

What is a wrapper class?

Front

A wrapper class encapsulates the functionality of a class. A wrapper class gives primitive data types object behavior.

Back

Do Objects added to a TreeSet require implementations of Comparable

Front

TreeSet inherits from Comparable interface

Back

Can you force garbage collection?

Front

No. You can request garbage collection using System.gc().

Back

Can you perform operator overloading?

Front

No. Java does not support it like C does.

Back

What is the difference between List and Set

Front

A List allows duplicates. A set does not allow duplicates. If a duplicate tries to enter the array, it is ignored and no error is thrown.

Back

What Collection would not allow duplicate elements?

Front

Set Collection interface does not allow duplicates. When you try to add a duplicate, it ignores it and does not throw an error.

Back

What is a class?

Front

A class is the blueprint to an object.

Back

What are the access modifiers?

Front

public: accessible anywhere in the program. protected: accessible to the packages and subclasses outside the package. default: accessible to the package only. private: accessible to the class only.

Back

What are some classes that implement SortedSet

Front

TreeSet ConcurrentSkipListSet

Back

What are constructors and when are they called?

Front

A constructor is a block of code similar to a method, except it doesn't have a return type. It is called when an instance of an object is instantiated. A constructor has the same name as a class. The default constructor is given if no other constructors are written and takes no parameters. Constructors return objects, or return an exception. they cant return null.

Back

Can you describe singletons?

Front

Singletons is a design pattern. A singleton is when you create a single instance of something.

Back

What is the Reflection API?

Front

Reflection gives java run time knowledge of its methods and variables. Benefits: extensible features and debugging. Drawbacks: overhead and security risks.

Back

Section 2

(50 cards)

What are the non access modifiers?

Front

Non access modifiers provide functionality to classes, methods and variables. Static: allows access without creating an object instance Final: finalizes the implementation. Synchronized: prevents threads from accessing resources at the same time. Transient: prevents method from becoming serialized. Volatile: makes class thread safe.

Back

List some object methods

Front

hashCode. clone. equals. finalize. getClass. notify. notifyAll. toString. wait.

Back

Can you explain threads?

Front

A thread is an independent path of execution in a program. A thread has its own stack. Threads share resources. Threads are lightweight compared to processes.

Back

Can you explain exceptions?

Front

Exceptions are events that occur during the execution of a program that inturrupt the flow of operations. An Exception is an object that wraps an error event within a method that contains information about the error.

Back

What is the root interface of the Collection API

Front

Collection

Back

What are intrinsic locks?

Front

Intrinsic locks enforce exclusive access to thread resources. Synchronization is built around intrinsic locks.

Back

What are unchecked exceptions?

Front

Unchecked exceptions are exceptions that inherit from Error or RuntimeException. Code still compiles if there is an unchecked exception. unchecked exceptions are: StackOverflowError. NullPointerException. ArrayIndexOutOfBoundsException. NumberFormatException.

Back

What is included in the JDK?

Front

JRE Garbage Collector JVM

Back

Does the Comparator interface declare the compareTo method?

Front

No! The Comparable interface implements the compareTo method. The Comparator interface implements the compare method. compareTo method is used to define the Natural order an object, using by its ID. compare method is used to define other ways to compare two objects. compare method is used when you do not have access to the two classes you want to compare.

Back

What are virtual methods?

Front

A method which can be overridden.

Back

What are the primitive data types?

Front

byte short int long boolean char float double

Back

What is abstraction? Give an example.

Front

Abstraction is hiding the complex functionality of a method, while providing a simple method signature. Example: a remote control hides the complex details while giving an easy way to use it.

Back

Can the finalize method be overriden?

Front

Yes. If an object has a lock on a file or database table, you would want to override the finalize method to release the resources those objects are holding onto when the object is garbage collected.

Back

What are the differences between throw and throws?

Front

Throws is used to declare an exception. Throw is used to throw an exception explicitly. Throws is used in the method signature. Throw is used in the method body. Example: public void shutdown() throws Exception { throw new Exception("unable to shutdown"); }

Back

Where does the run method come from?

Front

run method comes from the Runnable functional interface.

Back

Can the synchronized keyword be used for a class?

Front

No. It can only be used for methods and code blocks.

Back

Explain the JVM, JRE, and JDK

Front

The JVM is the operating system java programs run on. The JRE is what java needs to run a java program. The JDK is the development environment a java program needs.

Back

When is garbage collection ran?

Front

Before an OutOfMemoryException is thrown.

Back

What are checked exceptions?

Front

Checked exceptions are forced by the compiler. Checked exceptions must be handled by a try catch block or be specified in the method signature. Checked exceptions: IOException. ServletException. FileNotFoundException Exception. ClassNotFoundException. ParseException. InstantiationException.

Back

What are short circuits?

Front

|| and &&

Back

What is in-variance?

Front

Back

Is map part of Collection?

Front

No. It is part of the Collection framework, but it does not implement the java.util.Collection Interface. Maps work with key value pairs.

Back

How do you prevent deadlock?

Front

Synchronization

Back

Does every method in a class that extends serializable need to implement serializable?

Front

No. Not every method needs too.

Back

The changes to the instance variables of one object also change the instance varialbes of another object?

Front

No. Instance variable values are instance specific and are not shared among instances.

Back

What are the states of a thread

Front

Runnable Blocked Waiting Terminated

Back

What is deadlock?

Front

Deadlock is when two threads are holding resources that the other needs.

Back

What is the benefits of Generics?

Front

Generics provide compile time safety. Generics eliminate the need of casts. Generics provide stronger type checks.

Back

What is Generics?

Front

Generics allow methods to operate on objects of various types while providing compile time safety. This makes java a fully statically typed language.

Back

Why do we use OOP?

Front

OOP is good coding practice and makes large programs understandable and maintainable.

Back

Explain the Throwable heirarchy.

Front

Throwable branches to Error and Exception. Error exceptions are unchecked exceptions. Exception branches to checked exceptions and RunTimeException RunTimeException exceptions are unchecked exceptions.

Back

Can java programs control thread scheduling?

Front

Yes. Java programs can create, run, and manipulate threads

Back

What is co-variance?

Front

Back

How do you invoke a static method?

Front

class.staticMethod() you dont need to create an instance of the class.

Back

List some string methods

Front

equals. toUpperCase. toLowerCase. compareTo. compare. concat. split. length. replace. intern.

Back

What is autoboxing?

Front

Autoboxing is javas way of wrapping a primitive into its wrapper class automatically to give it object funtionality. Example: autoboxing: Integer a = 2; unboxing: int b = 5 + a

Back

What is the continue statment used for?

Front

the continue statement causes the loop to immediately jump to the next iteration of the loop

Back

Can you name a class that does not inherit from Iterable?

Front

HashTable

Back

Can you explain the Collection Framework?

Front

The Java Collection Framework, JCF, is a collection of interfaces that implement commonly used data structures. The three main sub interfaces are List, Set, Queue

Back

Can static methods be overridden?

Front

No. overridden methods happen at run time. static methods are looked up at compile time.

Back

What is the Comparator interface used for?

Front

The Comparator interface has the method compare(T obj1, T obj2) which should be used to make serveral sort methods to compare objects based on instance variables.

Back

What is serialization used for?

Front

It is used to send objects in byte stream form across a network. Benefits: Persists the state of objects. Platform independent.

Back

for loop vs while loop

Front

In a for loop, you define the variable, the condition, and how the loop should increment. In a while loop, you only define the condition

Back

What are the differences between collection and collections?

Front

Collection is an interface for collection classes. Collection interface defines methods common to structures which hold objects. List, Set, Queue are sub interfaces of collection. Collections is a utility class. Collections has static methods for doing operations on objects Collections has a method for finding the max element in a Collection. It also has sort method

Back

What is the Comparable interface used for?

Front

The Comparable interface has the method obj1.compareTo(T obj2) which should be used to compare objects based on user defined methods.

Back

Explain OOP

Front

OOP stands for Object Orientated Programming. OOP is creating parts of the program to act as objects that interact with each other. The pillars of OOP are abstraction, encapsulation, inheritance, and polymorphism.

Back

What is new to java 8?

Front

Lambda expressions. Interface default methods.

Back

What are some benefits of the JCF?

Front

The JCF reduces programming effort. The JCF promotes code reuse. The JCF allows developers to settle on a single way that data structures should be written.

Back

Can you explain Serialization?

Front

Serialization is converting methods into a byte stream that can be reverted into a copy of the code.

Back

What does javac do?

Front

javac compiles .java files into .class files which is byte code instructions for the JVM.

Back

Section 3

(15 cards)

What are the methods of a thread?

Front

start. sleep. yield. join. isAlive.

Back

What is a ternary operator?

Front

A ternary operator is a shorthand if then statement that has two operators and three operands. syntax: a condition ? return_if_true : return_if_false

Back

Can an interface extend another interface?

Front

Interfaces and classes can extend 1 or multiple interfaces. An interface cannot extend a class.

Back

Can you inherit a constructor?

Front

No.

Back

Can errors be thrown?

Front

The can but should not be thrown or caught

Back

What is the thread pool? What is its purpose?

Front

So java doesn't need to create threads. Any threads that aren't new, blocked, or terminated are in the thread pool.

Back

How do you set up a connection using JDBC?

Front

create a .properties file. Set database location url set password set username Configure the driver manager import the driver manager create a connection object and use the get connection method. create the connection.

Back

Can you name some jdbc interfaces?

Front

statement prepared statement callable statement connection driver result set

Back

What are the differences between statement and prepared statement?

Front

statement is used to execute normal sql queries. prepared statement is used if parameters are to be added during run time. prepared statement prevents sql injection. prepared statement extends statement.

Back

What is the deployment descriptor?

Front

web.xml

Back

What is the 'this' keyword used for?

Front

Three primary situations: To disambiguate variable references. When there is a need to pass the current class instance as an argument to a method of another object. As a way to call alternate constructors from within a constructor.

Back

What are the different types of polymorphism?

Front

Method over loading is compile time. The compiler checks the number of parameters. Method over riding is run time.

Back

What is the difference between Set and List

Front

Both are sub interfaces of Collection. Set cannot contain duplicate elements, but list can.

Back

Name reserved words in java that are not key words

Front

const goto reserved words are words a programmer can't use as variable names. Key words are words java uses to perform functionality.

Back

Can you inherit static methods?

Front

No.

Back