QUES PAPER FOR JAVA
https://goo.gl/forms/bP8HvK8e6CIIUx3h1
QUES PAPER FOR SQL
https://goo.gl/forms/UxymlpeQ6mKja9rz2
https://goo.gl/forms/bP8HvK8e6CIIUx3h1
QUES PAPER FOR SQL
https://goo.gl/forms/UxymlpeQ6mKja9rz2
Subexpression
|
Matches
|
|
^
|
Matches
beginning of line.
|
|
$
|
Matches
end of line.
|
|
.
|
Matches
any single character except newline. Using m option allows it to match
newline as well.
|
|
[...]
|
Matches
any single character in brackets.
|
|
[^...]
|
Matches
any single character not in brackets
|
|
\A
|
Beginning
of entire string
|
|
\z
|
End
of entire string
|
|
\Z
|
End
of entire string except allowable final line terminator.
|
|
re*
|
Matches
0 or more occurrences of preceding expression.
|
|
re+
|
Matches
1 or more of the previous thing
|
|
re?
|
Matches
0 or 1 occurrence of preceding expression.
|
|
re{
n}
|
Matches
exactly n number of occurrences of preceding expression.
|
|
re{
n,}
|
Matches
n or more occurrences of preceding expression.
|
|
re{
n, m}
|
Matches
at least n and at most m occurrences of preceding expression.
|
|
a| b
|
Matches
either a or b.
|
|
(re)
|
Groups
regular expressions and remembers matched text.
|
|
(?:
re)
|
Groups
regular expressions without remembering matched text.
|
|
(?>
re)
|
Matches
independent pattern without backtracking.
|
|
\w
|
Matches
word characters.
|
|
\W
|
Matches
nonword characters.
|
|
\s
|
Matches
whitespace. Equivalent to [\t\n\r\f].
|
|
\S
|
Matches
nonwhitespace.
|
|
\d
|
Matches
digits. Equivalent to [0-9].
|
|
\D
|
Matches
nondigits.
|
|
\A
|
Matches
beginning of string.
|
|
\Z
|
Matches
end of string. If a newline exists, it matches just before newline.
|
|
\z
|
Matches
end of string.
|
|
\G
|
Matches
point where last match finished.
|
|
\n
|
Back-reference
to capture group number "n"
|
|
\b
|
Matches
word boundaries when outside brackets. Matches backspace (0x08) when inside brackets.
|
|
\B
|
Matches
nonword boundaries.
|
|
\n,
\t, etc.
|
Matches
newlines, carriage returns, tabs, etc.
|
|
\Q
|
Escape
(quote) all characters up to \E
|
|
\E
|
Ends
quoting begun with \Q
|
|
No.
|
Character Class
|
Description
|
1
|
[abc]
|
a, b,
or c (simple class)
|
2
|
[^abc]
|
Any
character except a, b, or c (negation)
|
3
|
[a-zA-Z]
|
a
through z or A through Z, inclusive (range)
|
4
|
[a-d[m-p]]
|
a
through d, or m through p: [a-dm-p] (union)
|
5
|
[a-z&&[def]]
|
d, e,
or f (intersection)
|
6
|
[a-z&&[^bc]]
|
a
through z, except for b and c: [ad-z] (subtraction)
|
7
|
[a-z&&[^m-p]]
|
a
through z, and not m through p: [a-lq-z](subtraction)
|
1 | public class getLocationName { |
2 | return ( null ==cityName ? "" : cityName); |
3 | } |
1 | //Slower Instantiation |
2 | String bad = new String( "Yet another string object" ); |
3 | |
4 | //Faster Instantiation |
5 | String good = "Yet another string object" |
01 | import java.util.ArrayList; |
02 | import java.util.List; |
03 |
04 | public class Employees { |
05 |
06 | private List Employees; |
07 |
08 | public List getEmployees() { |
09 |
10 | //initialize only when required |
11 | if ( null == Employees) { |
12 | Employees = new ArrayList(); |
13 | } |
14 | return Employees; |
15 | } |
16 | } |
01 | import java.util.ArrayList; |
02 |
03 | public class arrayVsArrayList { |
04 |
05 | public static void main(String[] args) { |
06 | int [] myArray = new int [ 6 ]; |
07 | myArray[ 7 ]= 10 ; // ArraysOutOfBoundException |
08 |
09 | //Declaration of ArrayList. Add and Remove of elements is easy. |
10 | ArrayList<Integer> myArrayList = new ArrayList<>(); |
11 | myArrayList.add( 1 ); |
12 | myArrayList.add( 2 ); |
13 | myArrayList.add( 3 ); |
14 | myArrayList.add( 4 ); |
15 | myArrayList.add( 5 ); |
16 | myArrayList.remove( 0 ); |
17 | |
18 | for ( int i = 0 ; i < myArrayList.size(); i++) { |
19 | System.out.println( "Element: " + myArrayList.get(i)); |
20 | } |
21 | |
22 | //Multi-dimensional Array |
23 | int [][][] multiArray = new int [ 3 ][ 3 ][ 3 ]; |
24 | } |
25 | } |
01 | public class shutDownHooksDemo { |
02 | public static void main(String[] args) { |
03 | for ( int i= 0 ;i< 5 ;i++) |
04 | { |
05 | try { |
06 | if (i== 4 ) { |
07 | System.out.println( "Inside Try Block.Exiting without executing Finally block." ); |
08 | System.exit( 0 ); |
09 | } |
10 | } |
11 | finally { |
12 | System.out.println( "Inside Finally Block." ); |
13 | } |
14 | } |
15 | } |
16 | } |
01 | public class shutDownHooksDemo { |
02 |
03 | public static void main(String[] args) { |
04 | for ( int i= 0 ;i< 5 ;i++) |
05 | { |
06 | final int final_i = i; |
07 | try { |
08 | Runtime.getRuntime().addShutdownHook( |
09 | new Thread() { |
10 | public void run() { |
11 | if (final_i== 4 ) { |
12 | System.out.println( "Inside Try Block.Exiting without executing Finally block." ); |
13 | System.exit( 0 ); |
14 | } |
15 | } |
16 | }); |
17 | } |
18 | finally { |
19 | System.out.println( "Inside Finally Block." ); |
20 | } |
21 |
22 | } |
23 | } |
24 | } |