Interview Vocab Old

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is a variable?

- Devices used to store data - Assigned by giving a type and a name Kinds of Variables: 1) Instance variables - defined at the class level. Need not be initialized automatically initialized to default value 2) Class variables - defined with the static modifier static tells compiler there is exactly one copy of this variable in existence (regardless of how many times the class has been instantiated 3) Local Variable a method will often store its temporary state in local variables

What is a class?

- a blueprint for a data structure - Using this blueprint you can build as many of this particular data structure as you like

Array

- a container object that holds a fixed number of values of a single type - fixed length after creation

What is a list? How is it different than an arrayList?

- a list can't be instantiated - list is an interface, arraylist is an implementation of the list interface c. The list interface extends collection and declares the behavior of a collection that stores a sequence of elements i. elements can be inserted or accessed by their position in the list, using a zero based index ii. a list may contain duplicate elements iii. has some of its own methods in addition to those of collection

Abstract

- a type of nominative type system which cannot be instantiated directly - aka existential types - an abstract type may provide no implementation, or an incomplete implementation

What is an interface?

- abstract type - may only contain method signature and constant declarations - all methods of an interface do not contain implementation (method bodies) - cannot be instantiated, but rather implemented - a class that implements an interface must implement all of its methods described in the interface, or be an abstract class - Benefit: simulate multiple inheritance - a java class may implement and an interface may extend any number interfaces; however an interface may not implement an interface - used to encode similarities which the classes of various types share, but do not necessarily constitute a class relationship - another use: being able to use an object without knowing its type of class, but rather only that it implements a certain interface

What is an object?

- an instance of a class - each object has its own data, but its structure (type of data it stores & behaviors) are defined by the class

What is a method body?

- between curly braces - the method's code, including the declaration of local variables goes here

Public

- declares a member's access as public - public members are visible to all other classes - any other class can access a public field or method - other classes can modify public fields unless the field is declared as final

What is the heap?

- heap memory is used to store objects - no matter where an object is created in code (as member variable, local variable, class variable) they are always created inside heap space - the heap is the runtime data area from which memory for all class instances and arrays is allocated - heap storage for objects is reclaimed by an automatic storage management system (garbage collector). Objects are never explicitly deallocated - may be of a specific size or may be expanded - objects, class variables, instance variables go on the heap - if you have memory leaks in your code, they will be on the heap (a java profiling tool can help debug this problem)

Private

- member access is only visible within the class, not any other (including subclasses) - the visibility of private members extends to nested classes

What is the Stack? What kinds of variables are created here?

- memory used to store local variables and method call - a JVM stack stores frames - it holds local variables and partial results and plays a part in method invocation and return

What does the static keyword mean?

- only one instance of a static field exists - since static methods do not belong to a specific instance, they can't refer to instance members - Two types of static members: 1) static fields 2) static methods

What is a method parameter?

- the variables that are listed as part of a method declaration - each parameter must have a unique name and defined data type - comma delimited

What does the final keyword mean?

- used for values you never expect to change - if your object is accessed by multiple threads and you don't declare its fields final, then you must provide thread-safety by some other means - Final Class - a final class can't be subclassed - final method - can't be overridden or hidden by subclasses. this is used to prevent unexpected behavior from a subclass altering a method that may be crucial to the function or consistency of the class - Final Variables - can only be initialized once either via an initializer or an assignment statement

What is a checked exception?

A checked exception is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent files) are subclasses of Exception d. a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the stack, or handle it somehow)

Static field

Static field: A field that's declared with the static keyword, like this: private static int ballCount; The position of the static keyword is interchangeable with the positions of the visibility keywords (private and public, as well as protected). As a result, the following statement works, too: static private int ballCount; As a convention, most programmers tend to put the visibility keyword first. The value of a static field is the same across all instances of the class. In other words, if a class has a static field named CompanyName, all objects created from the class will have the same value for CompanyName. Static fields are created and initialized when the class is first loaded. That happens when a static member of the class is referred to or when an instance of the class is created, whichever comes first.

Static Method

Static method: A method declared with the static keyword. Like static fields, static methods are associated with the class itself, not with any particular object created from the class. As a result, you don't have to create an object from a class before you can use static methods defined by the class. The best-known static method is main, which is called by the Java runtime to start an application. The main method must be static, which means that applications run in a static context by default. One of the basic rules of working with static methods is that you can't access a nonstatic method or field from a static method because the static method doesn't have an instance of the class to use to reference instance methods or fields.

48. What is a try/catch?

a. A method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following: b. A catch statement involves declaring the type of exception you are trying to catch. If an exception occurs in protected code, the catch block (or blocks) that follows the try is checked. If the type of exception that occurred is listed in a catch block, the exception is passed to the catch block much as an argument is passed into a method parameter.

60. What is a static nested class?

a. A nested class is a member of its enclosing class. Nonstatic nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private. Static nested classes do not have access to other members of the enclosing class. b. Note: A static nested class interacts with the instance members of its outer class (and other classes) just like any other toplevel class. In effect, a static nested class is behaviorally a toplevel class that has been nested in another toplevel class for packaging convenience. c. Terminology: Nested classes are divided into two categories: static and nonstatic. Nested classes that are declared static are called static nested classes. Nonstatic nested classes are called inner classes.

41. What is a superclass?

a. A superclass is a class that has been extended by another class. It allows the extending class to inherit its state and behaviors. b. also known as parent or base class

Switch Statement

a. A switch statement gives you the option to test for a range of values for your variables. They can be used instead of long, complex if ... else if statements. b. Each case that you define can execute a different piece of code c. if a parameter is entered that is not one of the cases you define, the default case's code is executed

55. What is an accessor? What is a mutator?

a. Accessor Getter b. Mutator Setter c. One of the ways we can enforce data encapsulation is through the use of accessors and mutators. The role of accessors and mutators are to return and set the values of an object's state. This article is a practical guide on how to program them in Java.

Overload

a. Allows a class to have two or more methods having the same name if argument lists are different b. Argument lists could differ in: i. Number of parameters ii. Data type of parameters iii. Sequence of data type of parameters c. Examples i. public void disp(char c) { implementation 1 } ii. public void disp(char c , int num){ implementation 2 }

54. What does API stand for?

a. Application Programming Interface

34. What does it mean if a class is cohesive?

a. Cohesion refers to what the class (or module) will do. Low cohesion would mean that the class does a great variety of actions and is not focused on what it should do. High cohesion would then mean that the class is focused on what it should be doing, i.e. only methods relating to the intention of the class. b. an interface should do one thing and do it well aka needs to be cohesive c. cohesion refers to the degree to which the elements of a module belong together d. a measure of how strongly related each piece of functionality expressed by the source code of a software module is

56. What is a constructor?

a. Constructor in java is a special type of method that is used to initialize the object. Java constructor is invoked at the time of object creation. It constructs the values i.e. provides data for the object that is why it is known as constructor b. A constructor in Java is a block of code similar to a method that's called when an instance of an object is created. Here are the key differences between a constructor and a method: i. A constructor doesn't have a return type. ii. The name of the constructor must be the same as the name of the class. iii. Unlike methods, constructors are not considered members of a class. iv. A constructor is called automatically when a new instance of an object is created.

36. What is data hiding?

a. Data hiding is a software development technique specifically used in object-oriented programming (OOP) to hide internal object details (data members). Data hiding ensures exclusive data access to class members and protects object integrity by preventing unintended or intended changes. b. Data hiding also reduces system complexity for increased robustness by limiting interdependencies between software components. c. Data hiding is also known as data encapsulation or information hiding.

Override

a. Declaring a method in a subclass which is already present in its parent class b. Method signature is the same

42. What is a subclass?

a. Definition: A subclass is a class that extends another class. The subclass inherits the state and behaviors of the class it extends. b. Also Known As: derived class, child class

33. What does encapsulation mean?

a. Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction. b. Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods. c. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding. d. Encapsulation can be described as a protective barrier that prevents the code and data being randomly accessed by other code defined outside the class. Access to the data and code is tightly controlled by an interface. e. The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this feature Encapsulation gives maintainability, flexibility and extensibility to our code.

57. What does the term generic mean?

a. Generalization is the process of extracting shared characteristics from two or more classes, and combining them into a generalized superclass. Shared characteristics can be attributes, associations, or methods.

What is a Map? How is it different than a HashMap?

a. Hashmap is an implementation of map b. all properties of map are attained by hashmap c. To have the advantage of performance, the HashMap object can be assigned explicitly with initial capacity and load factor. The capacity gives the existing storage capability and the load factor gives increment rate of providing additional capacity when the existing capacity is exhausted. The default load factor is 0.75 and this value gives optimum performance level.

35. What is the single responsibility principle?

a. In object-oriented programming, the single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.

50. How is the import keyword used?

a. It declares a Java class to use in the code below the import statement. Once a Java class is declared, then the class name can be used in the code without specifying the package the class belongs to. b. Use the '*' character to declare all the classes belonging to the package.

52. What is JavaDoc?

a. Javadoc is a documentation generator from Oracle Corporation for generating API documentation in HTML format from Java source code. The HTML format is used to add the convenience of being able to hyperlink related documents together.

59. What is a local class?

a. Local classes are classes that are defined in a block, which is a group of zero or more statements between balanced braces. You typically find local classes defined in the body of a method. b. A class that is created inside a method is known as local inner class. If you want to invoke the methods of local inner class, you must instantiate this class inside the method.

51. What is a package?

a. Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc. b. http://www.tutorialspoint.com/java/java_packages.htm c. A Java package is a mechanism for organizing Java classes into namespaces similar to the modules of Modula, providing modular programming in Java. Java packages can be stored in compressed files called JAR files, allowing classes to be downloaded faster as groups rather than individually.

53. What is scope?

a. Scope refers to the lifetime and accessibility of a variable. How large the scope is depends on where a variable is declared. For example, if a variable is declared at the top of a class then it will accessible to all of the class methods. If it's declared in a method then it can only be used in that method.

58. What are the two categories of nested classes?

a. Static (Static nested class) b. NonStatic (inner classes) c. because inner classes are associated with a particular instance of the surrounding class, it can't have any static members of its own d. ***no such thing as a static inner class

49. What does the throws keyword mean?

a. The Java throws keyword is used to declare an exception. It gives information to the programmer that there may occur an exception so it is better for the programmer to provide the exception handling code so that normal flow can be maintained. b. Exception Handling is mainly used to handle the checked exceptions. If there occurs any unchecked exception such as NullPointerException, it is programmers fault that he is not performing check up before the code being used.

47. What does a finally block do?

a. The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated. b. The only time finally won't be called is if you call System.exit() or if the JVM crashes first.

40. What is an abstract base class?

a. a class that can't be instantiated because it is either labeled as abstract or it simply specifies abstract methods b. may provide implementation of some methods and may also specify virtual methods via signatures that are to be implemented by direct or indirect descendants of the abstract class c. Before a class derived from an abstract class can be instantiated, all abstract methods of its parent classes must be implemented by some class in the derivation chain

What is inheritance?

a. a mechanism where in a new class is derived from an existing class. Classes can inherit properties or methods from their parent class b. a class that is derived from another class is called a subclass (aka derived, extended, or child class)

64. What is composition? How is it used?

a. a relationship between two classes that is based on the aggregation relationship b. composition takes the relationship one step further by ensuring that the containing object is responsible for the lifetime of the object it holds c. if object B is contained by object A, then object A is responsible for the creation and destruction of Object B. d. Unlike aggregation, object B can't exist without object A

74. What is a pipeline?

a. a sequence of aggregate operations b. comprised of the following: A data source most commonly this is a Collection but it could be an array, the return from a method call, or some sort of I/O channel.

44. What does it mean to be loosely coupled?

a. a system's components has or makes use of little or no knowledge of the definitions of other separate components b. Loose coupling is an approach to interconnecting the components in a system or network so that those components, also called elements, depend on each other to the least extent practicable. Coupling refers to the degree of direct knowledge that one element has of another.

Dif between while and do while loop

a. a while loop checks that the condition is true before executing the loop and continues to execute the loop until the condition becomes false. b. a do while loop executes the loop first and then checks the condition to see if it should execute again. c. a do while loop will always execute at least one time.

39. What is a base class?

a. aka parent or superclass b. A base class is a class, in an object-oriented programming language, from which other classes are derived. It facilitates the creation of other classes that can reuse the code implicitly inherited from the base class (except constructors and destructors). A programmer can extend base class functionality by adding or overriding members relevant to the derived class.

71. What is a lambda?

a. an anonymous function that you can use to create delegates or expression free types b. by using lambda expressions, you can write local functions that can be passed as arguments or returned as the value of function calls

73. What are aggregate operations?

a. an operation that is performed on a data structure such as an array as a whole rather than performed on an individual element b. aggregate operations and lambdas perform actions on the object in a collection

37. What does it mean if one class is derived from another class?

a. definition of inheritance b. Definitions: A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class)

38. What does it mean if one class extends another class?

a. it is a subclass of the class that it extends

62. Under what conditions can a local class access variables in the enclosing scope?

a. nonstatic nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private b. static nested classes do not have access

66. Is the Java language pass by value or pass by reference?

a. pass by value b. java passes objects as references and those references are passed by value

68. What does pass by reference mean?

a. passes in a reference to a variable b. this is effectively the address of the variable in the function c. more efficient than passing by value and allows the function to change the variable directly

30. What is an unchecked exception?

a. represent defects in the program (bugs) often invalid arguments passed to a nonprivate method. To quote from The Java Programming Language, by Gosling, Arnold, and Holmes: "Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time." b. are subclasses of RuntimeException, and are usually implemented using IllegalArgumentException, NullPointerException, or IllegalStateException c. a method is not obliged to establish a policy for the unchecked exceptions thrown by its implementation (and they almost always do not do so)

43. What is specialization?

a. specialization means creating new subclasses from an existing class. If it turns out that certain attributes, associations, or methods only apply to some of the objects of the class, a subclass can be created. The most inclusive class in a generalization/specialization is called the superclass and is generally located at the top of the diagram. The more specific classes are called subclasses and are generally placed below the superclass

61. What level of access to the properties and methods of the enclosing class does a static nested class have?

a. static nested classes do not have access to other members of the enclosing class

46. What does it mean to cast a variable?

a. taking an Object of one particular type and "turning it into" another Object type. b. With objects, you can cast an instance of a subclass to its parent class. c. Casting an object to a parent class is called upcasting. d. explicitly convert one type to another e. To upcast a Child object, all you need to do is assign the object to a reference variable of type Parent. The parent reference variable cannot access the members that are only available in Child. Because parent references an object of type Child, you can cast it back to Child. It is called downcasting because you are casting an object to a class down the inheritance hierarchy. Downcasting requires that you write the child type in brackets. For example:

65. What is the default constructor?

a. the noargument constructor that is automatically generated unless you define another constructor b. it initializes and unanitializes fields to their default values

69. What is garbage collection?

a. the process of automatically detecting memory that is no longer in use and allowing it to be used again b. saves the programmer from explicitly disposing of the memory c. a form of automatic memory management d. an object is garbage collected when its reference count is zero

70. How does the garbage collector know when to return memory to the heap?

a. when the reference count for an object is zero ???

67. What does pass by value mean?

a. you are making a copy in memory of the actual parameter's value that is passed in b. a copy of the contents of the actual parameter

Protected

accessible inside class or subclass

What is a collection?

b. A collection — sometimes called a container — is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data. Typically, they represent data items that form a natural group, such as a poker hand (a collection of cards), a mail folder (a collection of letters), or a telephone directory (a mapping of names to phone numbers). If you have used the Java programming language — or just about any other programming language — you are already familiar with collections.

63. What is shadowing?

b. Shadowing refers to the practice in Java programming of using two variables with the same name within scopes that overlap. When you do that, the variable with the higherlevel scope is hidden because the variable with lowerlevel scope overrides it. The higherlevel variable is then "shadowed." c. You can access a shadowed class or instance variable by fully qualifying it — that is, by providing the name of the class that contains it.

Iterator

b. an interface that allows you to cycle through the elements of a collection

What is an ArrayList

b. extends AbstractList c. implements the list interface d. supports dynamic arrays that can grow as needed

72. What is a stream (in the context of the new Java 8 Collection API)?

b. represent sources and destinations of data c. a stream is data that you access in sequence d. InputStream and OutputStream are the basic stream classes in java e. an ordered sequence of bytes of undetermined length f. they exist as a communication medium g. a stream is not a data structure h. a stream carries items from the source through the pipeline

HashMap

b. uses a hashtable to implement the map interface c. it extends the AbstractMap class d. allows the execution time of basic operations like get and put to remain constant even for large sets e. contains values based on a key f. contains only unique elements no duplicates g. it maintains no order

Polymorphism

c. Definitions i. the ability to process objects of various types and classes through a single uniform interface ii. the ability of an object to take many forms...most common use: when a parent class reference is used to refer to a child class object iii. the capability of a method to do different things based on the object that it is acting upon. Allows you to define on interface and have multiple implementations d. Types i. Method overloading ii. Method overriding

29. What is an exception?

c. a problem that arises during the execution of your program d. Categories Checked exceptions, Runtime exceptions, Errors iii. Errors: - These are not exceptions at all, but problems that arise beyond the control of the user or the programmer. Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation.

What makes up a method's signature?

name and parameter list only

What is a variable declaration?

saying that a variable exists give it a type and a name

32. What is a runtime exception?

unchecked b. A runtime exception is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compilation.

What is variable assignment?

use = to assign a value to a declared variable


Set pelajaran terkait

2-2 Properties of Quadratic Functions in Standard Form

View Set

Absorption and Variable Income Statements

View Set

Appointment Scheduling Chapter 9

View Set

Classroom and Grading Expectations

View Set

6.3.6 Practice Questions Networking Media

View Set

Health Promotion and Maintenance Practice Exam

View Set