Technical Interview non-OOP harder

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is agile methodology? What about SCRUM?

- Iterative and incremental development - Adaptive planning rather than predictive planning - Flexible response to changes - Software delivery is the measure of progress Scrum is a subset of Agile.

What is a bit? What is a byte?

A bit is the smallest unit of digital information, representing a binary value of either 0 or 1. On the other hand, a byte is a collection of 8 bits. It is commonly used to represent a single character or a small amount of data. Since using binary number system, a single byte can represent 2^8 or 256 different values. These values can range from 0 to 255 inclusive.

What is an inner class?

A class within a class. To access it, you must create an instance of the outer class and then an instance of the inner class. It is used to organize code. Also they can access attributes & methods of the outer class. An inner class can be private or protected (unlike normal classes) Ex. OuterClass myOuter = new OuterClass(); OuterClass.InnerClass myInner = myOuter.new InnerClass();

What is Spring Boot?

A java framework for Spring that does a lot of the configuration for you. Use Spring initializer.. just select Maven/Gradle, War/Jar, some dependencies, etc. You don't need to setup a Tomcat server to run your web application. You can just write code and run it as Java application because it comes with an embedded Tomcat server.

What are lambda expressions?

A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.

What is recursion?

A programming technique that causes a method to call itself in order to compute a result. must have a halting condition ex. def factorials(n): if n == 1: return 1 else: return n * factorial(n-1)

What is a relative path?

A relative path is a way to specify the location of a file or directory in relation to the current working directory. Relative paths are useful for navigating the file system without providing the complete or absolute path. They can be especially helpful when working with files in or near the current working directory, as they can save time by avoiding the need to type out the entire path. Me: also good if might not be deployed in same exact path on each server . current dir .. parent dir

What is a servlet?

A servlet is a class that extends HttpServlet. Use @WebServlet annotations with URI. need to complete doGet and/or doPost methods which have request and response parameters. Often you will add things to the HttpSession (which can be accessed by the jsp). session.setAttribute("vehiclesFromSearch", vehiclesFromSearch) request dispatcher... send a jsp.

What are variable arguments?

Allows an undefined number of arguments. use ... Ex. public int sum(int... numbers) {blah} example.sum() example.sum(1,2,3); example.sum(1,2,3,4); Inside the method, you basically use it like an array. for (int number : numbers) { sum += number; }

6. Describe some of the data structures you used along with advantages/disadvantages of each. (Lists, Maps, trees etc)

ArrayList as opposed to Array -ArrayList is resizeable while array is not (so you have to create a new one to add something) -can't use ArrayList w/ primitive types.. so have to convert them to use wrapper classes -ArrayList has add, remove, get, set, clear, size, contains -Can use Collections.sort(myNumbers); to put in order cars.get(0); LinkedList is similar but can only add, get, or remove from front and back contains HashMap - key/value pairs You can access items with their key instead of a random index .put(key, value).. .get(key).. .remove(key).. .clear().. .size() containsKey() containsValue() Loop through the items of a HashMap with a for-each loop. Use the keySet() method if you only want the keys, and use the values() method if you only want the values: HashSet - every item is unique .add() .contains() .remove() .clear() .size() no .get (sets don't have this) -for all of these, can't use ArrayList w/ primitive types.. so have to convert them to use wrapper classes Stack - last-in-first-out Queue - first-in-first-out

What are some different number systems?

Decimal (base 10) Uses digits 0-9 Each place is 10x ...100, 10, 1 Binary (base 2) Uses digits 0,1 Each place is 2 ...256,128,64,32,16,8,4,2,1 Octal (base 8) Uses digits 0-7 Each place is 8 ...512,64,8,1 Hexadecimal (base 16) Uses digits 0-9, A=10, B=11, C=12, D=13, E=14, F=15 Each place is 16x ...256, 16, 1

What is an anonymous class?

Define: A class without a name. Explain: Use this whenever you're only going to use this class once Example: Comparator<String> reverseComparator = new Comparator<String>() {...}

What's the difference between an array and arrayList?

Define: Array is a fixed length data structure whereas ArrayList is a part of collection framework and is dynamic. Explain: We cannot change length of array once created in Java but ArrayList can be changed. We cannot store primitives in ArrayList, it can only store objects. But array can contain both primitives and objects in Java. Example: I use an ArrayList when I need flexibility in size (adding and removing items). I use Array for primitive types (int or boolean). Array is also faster and takes less memory (but it doesn't really matter).

What is exception handling in Java and what are the advantages of exception handling?

Exception Handling is the technique of handling unexpected failures that could occur in a program so that the program does not terminate and normal execution flow is maintained. Consider an example program where we have 6 statement blocks as shown in the below image. Statements 1 and 2 execute successfully. While executing the statement 3 block, an unexpected error occurred. Now the Java program checks if there is any exception-handling mechanism present. If an exception handling block is present, then the exception is handled gracefully and the program continues with the execution of the statement 4 block. If not, the program gets terminated. 1. The most important advantage of having an exception-handling technique is that it avoids abnormal program termination and the normal flow of the program is maintained. 2. Provides flexibility to the programmers to define/handle what should occur in cases of failures/errors thereby making the applications more robust and immune to unexpected scenarios. 3. Provides stable user experience in cases of failures by providing means to let the user know what made the program fail.

What is XML?

Extensible Markup Language Used for storing and exchanging data as text. pom.xml HTTP Requests

What is an IP address? Domain name? URL? Http?

IP address - every device that connects to the Internet has a unique IP address. Ex. 22.231.113.64 A domain name is the human-friendly version of an IP address. DNS, or the Domain Name System, translates human readable domain names (for example, www.amazon.com) to machine readable IP addresses (for example, 192.0.2.44). URL - uniform resource locator - A complete address to access and interact with resources on www. Traditionally would access the HTML file that represents the webpage. Format: protocol: domain name/path to file?parameters#Anchor HTTP is Hyper Text Transfer Protocol... to communicate/deliver info between web clients and web servers on the www

Functional Programming

In declarative programming, there are no statements. Instead, programmers use expressions to tell the computer what needs to be done, but not how to accomplish the task. If you are familiar with SQL or regular expressions, then you have some experience with the declarative style

What are the primary interfaces and objects in java util package?

Includes Collections Framework: Set, HashSet, SortedSet, And Maps Interface: HashMap, Hashtable, Queue, List (ArrayList, LinkedList) There are also scanner & iterator

What is JSON?

JSON: JavaScript Object Notation - a syntax for storing and exchanging data as text. Can be used to exchange data between between a browser and a server. We can work with the data as JavaScript objects, with no complicated parsing. var myObj = {name: "John", age: 31, city: "New York"};var myJSON = JSON.stringify(myObj); Better than XML b/c XML is much more difficult to parse than JSON. JSON is parsed into a ready-to-use JavaScript object.

Pass by value vs. pass by reference

Java is always pass-by-value. Unfortunately, when we pass the value of an object, we are passing the pointer (not the actual memory address) to it. x = 5; y = x; y += 2; now x=5 & y=7 (x does not equal 7). Class test { int x; } static void main { Test test1 = new Test(); test1.x = 5; Test test2 = test1; test2.x += 2; } Now test1.x & test2.x = 7 because test1 & test2 are the exact same object Pass by value = primitives and immutable object. String & all wrapper classes are immutable so they will be pass by value (because a new one is getting made each time... the values are not getting changed). Pass by reference = mutable objects.

What is an enum?

Like a class but group of constants (unchangeable variables, like final variables) It can only be one. Example: clothingSize.SMALL clothingSize.MEDIUM clothingSize.LARGE Months, colors, etc Can have also methods. Cannot be used to create objects, and it cannot extend other classes (but it can implement interfaces).

What is the difference of Java from C++?

No pointers, so cannot access an object by referencing it's memory location. Java is a put OOL - classes only. Has garbage collection, so we don't need to manage memory. Java doesn't support multiple inheritance (only implementing multiple interfaces).

Why is Java so good/popular?

Platform independent & pure Object Oriented (everything is a class... can only write OOP programs)- easy to maintain

What is the Coursera Seven step approach to solving programming problems?

Problem Statement → Working Code (that solves the problem statement): 1. Work Example By hand Get stuck here? Maybe the problem is unclear - need to clarify the requirements. Maybe you lack domain knowledge - physics, etc. 2. Write Down What you did step by step (algorithm = clear step by step directions) Be as exact as possible Use your specific example that you just worked (don't generalize yet) 3. Find Patterns (reptition - looping, conditions - if, else, values) - if this part is difficult, redo step 1 & 2 with different inputs An algorithim for any instance of the problem, not just your specific case Get stuck here? Try steps 1 & 2 with a different instance. 4. Check by Hand - Try algorithm out on different example to see if it works as expected (try on different inputs) Pick at least one different input and see if your algorithm works for that case 5. Translate to Code Using programming language syntax 6. Run Test Cases 7. Debug Failed Test Cases (use scientific method) a. Sci Method (Observe a phenomenon, ask a question, gather info & apply expert knowledge (see below), Form hypothesis, test hypothesis (run program), if reject go back to gather knowledge step OR accept hypothesis, act on it and fix program b. Gather info (Use print statements, Debugging tools (online), Execute code by hand) c. Hypotheses (must be Testable, Actionable, Specific)

What are RESTful webservices? What is RESTful API design, and what are some best practices you follow when designing an API?

RESTful web services are loosely coupled, lightweight web services that are particularly well suited for creating APIs for clients. In REST architecture, a REST Server simply provides access to resources and REST client accesses and modifies the resources. A RESTful web service usually defines a URI, resource representation such as JSON and set of HTTP Methods. Use HTTP Methods: GET − Provides a read only access to a resource. POST − Used to create a new resource. DELETE − Used to remove a resource. PUT − Used to update a existing resource or create a new resource.

Functional Interface

SAM - Single Abstract Method.. can only have one abstract method, but can have additional non-abstract methods can use lambda expressions We have a functional interface and call it through Lamba expression. Without implementing it somewhere. All lambda expressions will fail if you add another abstract method. Would fail at runtime. Instead you can add an annotation @FunctionalInterface above the class so that others can see and compiler will catch it.

What is syntax vs semantics?

Syntax - what the code says, grammar Semantics - meaning of what the code does, meaning

Java API

The Java Applications Programming Interface that specifies the wide variety of classes that come with the Java platform. can import classes (ex. import java.util.Scanner) or packages (ex. import java.util*;) using the import keyword

What are some of the best practices to be followed while dealing with Java Exception Handling?

The following are some of the best practices that have to be followed while developing Exception Handling in Java: Use Specific Exception as much as possible for the sake of better messages and easier debugging. Throw Exceptions early in the program. This follows the Fail-Fast approach to development. Catch Exceptions late in the program, i.e, the caller has to handle the exceptions. If you are using Java 7 and above versions, make use of the feature of the try-with-resources block to close the resources properly. In this way, we do not have to remember to ensure that all resources have been closed in the finally block. Always log the exception messages with meaningful messages. This helps in easier debugging. Use multiple catches that follow the rule of most specific exceptions at the top and the most generic exceptions at the bottom. If the exception types provided by Java do not match your use case, make sure to use custom exceptions with meaningful error messages. While creating custom messages, the naming convention of ending the exception name with Exception has to be followed. Whenever your method throws any exception, document this using the Javadoc and describe that briefly using the @throws parameter. Since exceptions are costly, be responsible while throwing them. Only throw them if it makes sense.

Types of loops and when/how to use them?

The while loop loops through a block of code as long as a specified condition is true.... good if you don't know how many times you'll need to go through int i = 0; while (i < 5) { System.out.println(i); i++; } //remember you still need to iterate I've used while loop for user input with an escape key Used for reading input while scanner has next line The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true. When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop often for arrays when you're going to do something based on the index value for-each" loop, which is used exclusively to loop through elements in an array

What are threads?

Threads allows a program to operate more efficiently by doing multiple things at the same time. Threads can be used to perform complicated tasks in the background without interrupting the main program. There are two ways to CREATE a thread. 1. It can be created by extending the Thread class and overriding its run() method. 2. implement the Runnable interface. Then you must run the thread... The major difference is that when a class extends the Thread class, you cannot extend any other class, but by implementing the Runnable interface, it is possible to extend from another class as well, like: class MyClass extends OtherClass implements Runnable. Concurrency problems: Because threads run at the same time as other parts of the program, there is no way to know in which order the code will run. When the threads and main program are reading and writing the same variables, the values are unpredictable.

What is UML?

Unified Modeling Language. This is a graphical notation specifically for drawing diagrams of an object-oriented system. The Unified Modeling Language is a general-purpose, developmental, modeling language in the field of software engineering that is intended to provide a standard way to visualize the design of a system.

What is JUnit? What are some assertions?

Unit Testing Framework.. library. Ensure code meets design and behaves as it should. Regression testing. TDD. setUpClass() setUp() testMethodName() tearDown() tearDownClass() assertions: assertEquals assertNotEquals assertTrue assertFalse assertNull assertNotNull

What's the difference between Linux and Windows?

Unix environment (w/o Linux) will not have a GUI.. so will be using Command Line. File system is different - Unix/Linux uses tree-like hierarchical file system. Everything is a file with Unix - even hard drives, printers, etc. Files are case sensitive so you can have a file Blah and blah in the same directory. Linux & Mac both use Unix.

What are some conditional statements and when/how to use them?

Use if to specify a block of code to be executed, if a specified condition is true Use else to specify a block of code to be executed, if the same condition is false Use else if to specify a new condition to test, if the first condition is false Use switch to specify many alternative blocks of code to be executed Short Hand If...Else (Ternary Operator): variable = (condition) ? expressionTrue : expressionFalse;

What are packages?

Used to group related classes. Like a folder/file directory. two categories: Built-in Packages (packages from the Java API) User-defined Packages (create your own packages)

Frontend. What are RGB values for white and black?

White = 255, 255, 255 Black = 0, 0, 0

What is platform independence?

Write the java program once and compile it and then you can run it anywhere. You just need to install a version of JVM for your operating system. Your program will run on JVM. Can run the .class or .jar file on any computer. Older languages like C & C++ are not platform independent. Will need to change some things in the code, compile it, build it, then run it on MacOS.

What is multithreading in Java?

a Java feature that allows concurrent execution of two or more parts of a program for maximum utilization of CPU

What is an iterator used for and how do you use it?

an object that can be used to loop through collections to loop using an iterator Iterator<String> it = cars.iterator(); while(it.hasNext()) { System.out.println(it.next()); } Trying to remove items using a for loop or a for-each loop would not work correctly because the collection is changing size at the same time that the code is trying to loop.

garbage collection

automatic reclamation of memory occupied by objects that are no longer referenced finalize() is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. Generally avoid using finalize but could be used to close a scanner or something of the sort

What are some useful methods in java.lang.object?

clone, equals, toString, HashCode, finalize

How is the final modifier used?

final is something that can't be modified or overridden variable - value can't be changed method - can't be overridden class - can't be extended

Casting (converting b/t number types)

int myInt = 9; double myDouble = myInt; // widening casting: done automatically double myDouble = 9.78; int myInt = (int) myDouble; //narrowing casting - manual

Where are all the java data / time stuff? How do you access the current date or current time?

java.time To display the current date, import the java.time.LocalDate class, and use its now() method: To display the current time (hour, minute, second, and nanoseconds), import the java.time.LocalTime class, and use its now() method: To display the current date and time, import the java.time.LocalDateTime class, and use its now() method:

JDK vs JRE vs JVM

smallest to largest The JVM executes a computer program which has been compiled into Java bytecode. Java Runtime Environment (JRE) holds the JVM and provides the libraries. The Java Development Toolkit (JDK) is a software development environment. It encompasses JRE and the Dev Tools, compiler, and documentation.


Conjuntos de estudio relacionados

Cranial Nerve V: Trigeminal Nerve Branches

View Set

Insurance Regulations - Life Insurance

View Set

2) Alzheimers: Amyloid plaque formation

View Set

Chapter 3: Biology and Behavior Psych 2400

View Set

Ch 41 Upper GI Problems Questions

View Set