Revature Pre-placement Evaluation

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

throwing objects (C#)

"throw" statement allows you to create a custom error; used together with an exception class -you can throw an object if it is either directing or indirectly derived from the System.Exception class

"throw" and "throws" keywords

"throws": indicates what exception type may be thrown by a method "throw": used to throw an exception for a method

Properties of the String Class (C#)

Chars - gets the Char object at a specified position in the current String object Length - gets the number of characters in the current String object

Using packagename.classname

If you import package.classname then only declared class of this package will be accessible.

Using fully qualified name

If you use fully qualified name then only declared class of this package will be accessible. Now there is no need to import. But you need to use fully qualified name every time when you are accessing the class or interface. It is generally used when two packages have same class name e.g. java.util and java.sql packages contain Date class.

Advantages Of Packages

Java package is used to categorize the classes and interfaces so that they can be easily maintained. Java package provides access protection. Java package removes naming collision.

Abstract and Sealed Keywords (C#)

- "abstract" keyword = enables you to create classes and class members that are incomplete and must be implemented in a derived class -->cannot be instantiated; provides a definition of a base class that multiple derived classes can share -"sealed" keyword = enabled you to prevent the inheritance of a class or certain class members that were previously marked virtual **Derived classes of the abstract class MUST implement all abstract methods. When an abstract class inherits a virtual method from a base class, the abstract class can override the virtual method with an abstract method

Extending Multiple Interfaces

-A Java class can only extend one parent class. Multiple inheritance is not allowed. Interfaces are not classes, however, and an interface can extend more than one parent interface. -The extends keyword is used once, and the parent interfaces are declared in a comma-separated list.

WHY DO WE NEED SQL?

-Allows users to access data in the RDBMS -Allows users to describe the data -Allows users to define the data in a database and manipulate that data ***Allows to embed within other languages using SQL modules, libraries, and pre-compilers -Allows users to create and drop databases and tables -Allows users to create view, stored procedure, functions in a database -Allows users to set permissions on tables, procedures, and views

Similarities between an interface and a class

-An interface can contain any number of methods. -An interface is written in a file with a .java extension, with the name of the interface matching the name of the file. -The byte code of an interface appears in a .class file. -Interfaces appear in packages, and their corresponding bytecode file must be in a directory structure that matches the package name.

Extending Interfaces

-An interface can extend another interface in the same way that a class can extend another class. -The extends keyword is used to extend an interface, and the child interface inherits the methods of the parent interface.

Points to Remember (C# Program)

-C# is case sensitive -All statements and expressions must end with a semicolon (;) -The program execution starts at the Main method -Unlike Java, program file name could be different from the class name

Common String Manipulations (C#)

-Comparing Strings - compares strings -String Contains String - tests to find is a string is present in another string -Getting a Substring - looks for a substring within a larger string (index based) -Joining Strings - joins strings to form one string

SQL Statements

-DDL - Data Definition Language - CREATE, ALTER, DROP -DML - Data Manipulation Language - SELECT, INSERT, UPDATE, DELETE -DCL - Data Control Language - GRANT, REVOKE -TCL - Transaction Control Language - SAVEPOINT, ROLLBACK, COMMIT

Different Types of Joins

-INNER JOIN -LEFT JOIN -RIGHT JOIN -FULL JOIN

Using packagename.*

-If you use package.* then all the classes and interfaces of this package will be accessible but not subpackages. -The import keyword is used to make the classes and interface of another package accessible to the current package.

Program Structure (C#)

-Namespace declaration -A class -Class methods -Class attributes -A Main method -Statements and Expressions -Comments

string concatenation

-The String class includes a method for concatenating two strings : string1.concat(string2); -->This returns a new string that is string1 with string2 added to it at the end. -You can also use the concat() method with string literals: "My Name is".concat("Zara"); -Strings are most commonly concatenated with the "+" operator "Hello," + " world" + "!"

advantages and disadvantages of arrays

Advantages: -Code Optimization: It makes the code optimized, we can retrieve or sort the data efficiently. -Random access: We can get any data located at an index position Disadvantages: -Size Limit: We can store only the fixed size of elements in the array. It doesn't grow its size at runtime. To solve this problem, collection framework is used in Java which grows automatically.

Exception Heirarchy

All exception classes are subtypes of the java.lang.Exception class. The exception class is a subclass of the Throwable class. Other than the exception class there is another subclass called Error which is derived from the Throwable class. **NOTE: refer to study guide to review exception hierarchy figure

checked exception

An exception that must be caught or specifically declared in the header of the method that might generate it. -The compiler enforces that you handle them explicitly. -Methods that generate checked exceptions must declare that they throw them. -Methods that invoke other methods that throw checked exceptions must either handle them (they can be reasonably expected to recover) or let them propagate by declaring that they throw them

JAVA

An object-oriented programming language designed specifically for programs (particularly multimedia) to be used over the Internet. Java allows programmers to create small programs or applications to enhance websites.

Exception classes

C# exceptions are represented by classes which are mainly directly or indirectly derived from the System.Exception class

SQL

Structured Query Language; programming language used to communicate with data stored in a RDBMS; syntax = similar to English

"this" : to refer current class instance variable

The "this" keyword can be used to refer current class instance variable. If there is ambiguity between the instance variables and parameters, "this" keyword resolves the problem of ambiguity.

Using "super" to invoke parent class method (JAVA)

The super keyword can also be used to invoke parent class method. It should be used if subclass contains the same method as parent class. In other words, it is used if method is overridden.

Using "super" to invoke parent class constructor (JAVA)

The super keyword can also be used to invoke the parent class constructor. **Refer to study guide to review code example

Usage of "super" keyword (JAVA)

The super keyword in Java is a reference variable which is used to refer immediate parent class object. Whenever you create the instance of subclass, an instance of parent class is created implicitly which is referred by super reference variable. -super can be used to refer immediate parent class instance variable. -super can be used to invoke immediate parent class method. -super() can be used to invoke immediate parent class constructor.

"this" : to invoke current class constructor

The this() constructor call can be used to invoke the current class constructor. It is used to reuse the constructor. In other words, it is used for constructor chaining.

static variable

a variable defined in a class that has only one value for the whole class, which can be accessed and changed by any method of that class -The static variable can be used to refer to the common property of all objects (which is not unique for each object), for example, the company name of employees, college name of students, etc. -The static variable gets memory only once in the class area at the time of class loading. **Advantage = memory efficiency

Declaring Arrays

datatype [ ] arrayName; where, -datatype is used to specify the type of elements in the arrya -[ ] specifies the rank of the array; rank = size of the array -arrayName specifies the name of the array

Initializing Arrays

declaring an array doesn't initialize the array in the memory; -array = reference type; need to use "new" keyword to create an instance of the array

Exceptions

events that occur during the execution of programs that disrupt the normal flow of instructions -in Java, an exception is an object that wraps an error even that occurred within a method and contains: -->Information about the error including its type -->The state of the program when the error occurred -->Optionally, other custom information

Create Primary Key

generally, the primary key is created while creating the database and the table; can also be created after the creation of the table

Java Package

group of similar types of classes, interfaces and sub-packages 2 categories: -built-in -user-defined

static keyword

is used to declare members that do not belong to individual objects but to a class itself. The static can be: -Variable (also known as a class variable) -Method (also known as a class method) -Block Nested class

columns in database table

labeled with a descriptive name and have specific data type

array

object which contains elements of a similar data type. It is a data structure where we store similar elements. We can store only a fixed set of elements in a Java array -index based

virtual method

one whose behavior is determined by the implementation in a child class -used when a method's basic functionality is the same but sometimes more functionality is needed in the derived class **if a virtual method is declared abstract, it is still virtual to any class inheriting from the abstract class. a class inheriting an abstract method cannot access the original implementation of the method

Namespaces

organizes the names of program entities; collection of classes -Declaring Namespace -->keyword "namespace" followed by the namespace name

Sequence of program

package --> import --> class

Exception

problem that arises during the execution of a program C# - exception is a response to an exceptional circumstance that arises while the program is running -provide a way to transfer control from one part of the program to another

Errors

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

throw

program throws an exception when a problem shows up; done using the "throw" keyword

while loop

programming construct used to repeat a set of commands (loop) as long as (while) a boolean condition is true -condition = any expression; true = any non-zero value -when the condition becomes false, program control passes to the line immediately following the loop

"sealed" keyword (C#)

this modified prevents other classes from inheriting from it -can also us this modifier on a method or property that overrides a virtual method or property in a base class -->enables one to allow classes to derive from your class and prevent them from overriding specific virtual methods or properties ***Error to use abstract modifier with a sealed class; an abstract class must be inherited by a class that provides an implementation of the abstract methods or properties

relational database

type of database; uses a structure that allows us to identify and access data in relation to another piece of data in the database

finally block

used in association with a 'try-catch' block. always executed regardless of whether an exception is thrown. often used to clean up code.

SQL INSERT INTO

used to add new rows of data to a table in the database

"static" keyword (C#)

used to declare a static member, which belongs to the type itself rather than to a specific object; modifier can be used with classes, fields, methods, properties, operators, events, and constructors -static member cannot be referenced through an instance; referenced through the type name **Note: cannot be used with indexers, finalizers, or types other than classes **a constant or type declaration is implicitly a static member

SQL WHERE

used to filter records and retrieve only the necessary data

Handling Exceptions

- An exception is an object that is generated as the result of an error or an unexpected event. To prevent exceptions from crashing your program, you must write code that detects and handles them. - You can think of the code in the try block as being "protected" because the application will not halt if the try block throws an exception. -completed using the 'try-catch' block

unchecked exception

- errors and run time exceptions: the compiler does not enforce (check) that you handle them explicitly. - Methods do not have to declare that they throw them (in the method signatures). -It is assumed that the application cannot do anything to recover from these exceptions (at runtime). Example

Rules for SWITCH Statement (C# and JAVA)

-The variable used in a switch statement can only be integers, Convertable integers (byte, short, char), strings, and enums [JAVA] -The expression used in a switch statement must have an integral or enumerated type or be of a class type in which the class has a single conversion function to an integral or enumerated type [C#] -You can have any number of case statements within a switch. Each case is followed by the value to be compared to and a colon. -The value for a case must be the same data type as the variable in the switch and it must be a constant or a literal. -When the variable being switched on is equal to a case, the statements following that case will execute until a break statement is reached. -When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the switch statement. -Not every case needs to contain a break. If no break appears, the flow of control will fall through to subsequent cases until a break is reached. -A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.

Implementing Interfaces (JAVA)

-When a class implements an interface, you can think of the class as signing a contract, agreeing to perform the specific behaviors of the interface. If a class does not perform all the behaviors of the interface, the class must declare itself as abstract. -A class uses the implements keyword to implement an interface. The implements keyword appears in the class declaration following the extends portion of the declaration.

Differences between an interface and a class

-You cannot instantiate an interface. -An interface does not contain any constructors. -All of the methods in an interface are abstract. -An interface cannot contain instance fields. The only fields that can appear in an interface must be declared both static and final. -An interface is not extended by a class, it is implemented by a class. -An interface can extend multiple interfaces.

Differences between Virtual function and Abstract method

-abstract function cannot have functionality; any child MUST give their own version of this method but it's too general to even implement in the parent class -virtual function has the functionality that may or may not be good enough for the child class

Assigning Values to an Array

-assign values to individual array elements, by using the index number -assign values to the array at the time of declaration -create and initialize an array int [ ] marks = new int [5] { 1,2,3,4,5}; -you can also omit the size of the array int [ ] mars = new int [ ] { 1,2,3,4,5};

creating a string object (C#)

-by assigning a string literal to a String variable -by using a String class constructor -by using the string concatenation operator (+) -by retrieving a property or calling a method that returns a string -by calling a formatting method to convert a value or an object to its string representation

Some String Handling Methods

-char charAt(int index) - Returns the character at the specified index. -int compareTo(Object o) - Compares this String to another Object. -String concat(String str) - Concatenates the specified string to the end of this string. -boolean equals(Object anObject) - Compares this string to the specified object. -boolean equalsIgnoreCase(String anotherString) - Compares this String to another String, ignoring case considerations.

Interface

-collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface -may also contain constants, default methods, static methods, and nested types. Method bodies exist only for default methods and static methods -writing an interface is similar to writing a class. But a class describes the attributes and behaviors of an object. And an interface contains behaviors that a class implements. -unless the class that implements the interface is abstract, all the methods of the interface need to be defined in the class.

Accessing a package from other packages

-import package.*; -import package.classname; -fully qualified name.

Rules of Thumb ("static" keyword-C#)

-there is only one copy of each static field -not possible to use "this" to reference to "static" members or property accessors -if "static" keyword is applied to a class, all members to the class must be static -classes and static classes may have static constructors; static constructors are called some point between when the program starts and the class is instantiated

6 usages of "this" keyword (JAVA)

-this can be used to refer current class instance variable. -this can be used to invoke current class method (implicitly) -this() can be used to invoke current class constructor. -this can be passed as an argument in the method call. -this can be passed as argument in the constructor call. -this can be used to return the current class instance from the method.

"new" keyword (C#)

-used to create objects and invoke constructors -used to create instances of anonymous type -used to invoke the default constructor for value types **Note: id the "new" operator fails to allocate memory, it throws the exception, OutOfMemoryException

Declaring Interfaces

-using the "interface" keyword -similar to class declarations -interface statements are public be default **Refer to Interfaces section of study guide to review code

Rules to Remember-Interfaces (JAVA)

A class can implement more than one interface at a time. A class can extend only one class, but implement many interfaces. An interface can extend another interface, in a similar way as a class can extend another class.

Foreign Key

A primary key of one table that appears as an attribute in another table and acts to provide a logical relationship between the two tables; AKA referencing key

enhanced for loop

A special type of for loop that traverses an array or array list from beginning to end, binding a local variable to each element in the array or list. -declaration = the newly declared bloc variable is of a type compatible with the elements of the array you are accessing -->the variable will be available within the for block and its value would be the same as the current array element -expression = this evaluates to the array you need to loop through -->the expression can be an array variable or method call that returns an array

for loop

A typical looping construct designed to make it easy to repeat a section of code using a counter variable. The for loop combines the creation of a variable, a boolean looping condition, and an update to the variable in one statement.

else statement

The code to be executed if the if-condition evaluates to False in an if-statement. See also if-statement.

if statement

The common programming structure that implements "conditional statements"; if the condition is true, then the block of code inside the if statement is executed. If the condition is false then the first set of code after the end of the if statement (after closing curly brace) is executed

Final Keyword (JAVA)

The final keyword in java is used to restrict the user. -The java final keyword can be used in many context. -->Final can be: --->variable --->method --->class -The final keyword can be applied with the variables, a final variable that have no value it is called blank final variable or uninitialized final variable. -It can be initialized in the constructor only. The blank final variable can be static also which will be initialized in the static block only.

Declaring Interfaces (JAVA)

The interface keyword is used to declare an interface. -An interface is implicitly abstract. You do not need to use the abstract keyword while declaring an interface. -Each method in an interface is also implicitly abstract, so the abstract keyword is not needed. -Methods in an interface are implicitly public.

Collections in C#

specialized classes for data storage and retrieval; provide support for stacks, queues, lists, and hash tables -allocates memory dynamically to elements and accessing a list of items on the basis of an index

nested if statement

This is an if statement that appears inside another if statement; else if...else can also be nested in a similar way

SQL Joins

Used to combine rows from two or more tables, based on a common field between them

SQL SELECT

Used to select data from a database and returns the data in the form of a result table; result table = result-sets

Using "super" to refer parent class instance variable (JAVA)

We can use super keyword to access the data member or field of parent class. It is used if parent class and child class have same fields.

Usage of the "new" keyword (JAVA)

When you are declaring a class in java, you are just creating a new data type. A class provides the blueprint for objects. You can create an object from a class. Declaration : First, you must declare a variable of the class type. This variable does not define an object. Instantiation and Initialization : Second, you must acquire an actual, physical copy of the object and assign it to that variable. You can do this using the new operator. The new operator instantiates a class by dynamically allocating(i.e, allocation at run time) memory for a new object and returning a reference to that memory. This reference is then stored in the variable. Thus, in Java, all class objects must be dynamically allocated. The new operator is also followed by a call to a class constructor, which initializes the new object. A constructor defines what occurs when an object of a class is created. Constructors are an important part of all classes and have many significant attributes.

"this" : to invoke current class method

You may invoke the method of the current class by using the "this" keyword. If you don't use the "this" keyword, compiler automatically adds this keyword while invoking the method.

Arrays (C#)

a collection of variables of the same type stored at contiguous memory locations -for loops can be used to access array elements

Primary Key

a field that uniquely identifies a record in a table; -Table can only have 1 primary key-which can consist of single or multiple fields (multiple fields used as primary key = composite key) -if a table has a primary key defined on any field(s), then you cannot have two records having the same value of that field(s)

accessor method

a method that accesses an object but does not change it

catch block

a segment of code that can handle an exception that might be thrown by the try block that precedes it

what is a String?

a sequence of characters. In Java programming language, strings are treated as objects. -you can create String objects by using the new keyword and a constructor. **NOTE: The String class is immutable, so that once it is created a String object cannot be changed. If there is a necessity to make a lot of modifications to Strings of characters, then you should use String Buffer & String Builder Classes.

Interface (C#)

a syntactical contract that all the classes inheriting the interface should follow; defines properties, methods, and events which are the members of the interface -interface defines the "what" part of the syntactical contract and the deriving classes define the "how" -contain only the declaration of the members -responsibility of the deriving class to define the members **Abstract classes can serve the same purpose, to some extent, but only when a few methods are to be declared by the base class

switch statement

allows multi-way branching. In many cases, using a switch statement can simplify a complex combination of if-else statements. -each value is called a case -variable being switched on is checked for each switch case -possible to have nested switch statement

Database

collection of information that is organized so that it can easily be accessed, managed, and updated.

try block

contains code that might create exceptions you want to handle; followed immediately by 1 or more catch blocks -code within a 'try-catch' block is called protected code

"using" keyword (C#)

states that the program is using the names in the given namespace - program generally has multiple "using" statements **Note: refer to Namespaces section of study to review usage of the "using" keyword and how it changes the code

"this" keyword (C#)

refers to the current instance of the class and is also used as a modifier of the first parameter of an extension method

RDBMX

relational database management system; program that allows you to create, update, and administer a relational database

do-while loop

repeatedly executes a block of statements until a specified Boolean expression evaluates to false. -checks condition at the end of the loop -guaranteed to execute at least one time

Hash Table (C#)

represents a collection of key/value pairs that are organized based on the hash code of the key; uses key to access the elements in the collection

Queue (C#)

represents a first-in, first-out collection of objects -enqueue = adding items in the list -deque = removing items from the list

Stack (C#)

represents a last-in, first-out collection of an object -pushing = adding items in the list -popping = removing items from the list

ArrayList (C#)

represents and ordered collection of an object that can be indexed individually -alternative to array but you can add and remove items from a list at a specified position using an index and the array resizes itself automatically -allows dynamic memory allocation, adding, searching, and sorting items in the list **need "using" keyword for this; refer to study guide to inspect the code

string length (length())

returns the number of characters contained in the string object.

records

rows in the table (database)


Set pelajaran terkait

Chapter 09 Skeletal System: Articulations

View Set

CULTURE: CENTRAL, SOUTH, EAST, AND SOUTHEAST ASIA

View Set

bio 2 test 2 Final Exam Practice

View Set

Chapter 16: Agency Relationships

View Set

Psyc 352 Unit 10 - Theory of Mind

View Set

Lesson 2 Chemistry Basics Continued Quiz

View Set