IT Questions and Answers :)

Friday, August 17, 2018

Which of the following RegEx character sets does the '\w' meta-character most closely represent in Perl-compatible Regular Expression implementations?

Which of the following RegEx character sets does the '\w' meta-character most closely represent in Perl-compatible Regular Expression implementations?

  • [a-zA-Z0-9_]
  • [a-zA-Z]
  • [a-zA-Z0-9]
  • [a-zA-Z_] 

 
Which of the following RegEx character sets does the '\w' meta-character most closely represent in Perl-compatible Regular Expression implementations?

EXPLANATION

The "word" meta-character \w in RegEx will match the full alpha-numeric range, basically the full alphabet as well as number characters, and includes underscores.


Note that it matches more alphabet characters than the standard a through z: pretty much any alphabet character, such as 'ñ', also match.

http://www.w3schools.com/jsref/jsref_regexp_wordchar.asp
Share:

Monday, July 23, 2018

In programming, which of the following is a mechanism by which an object acquires the properties of another object?

In programming, which of the following is a mechanism by which an object acquires the properties of another object?

  • Anamorphism
  • Inheritance
  • Encapsulation
  • Polymorphism 

 
In programming, which of the following is a mechanism by which an object acquires the properties of another object?

EXPLANATION

‘Inheritance’ is the mechanism provided by Object Oriented Language, which helps an object to acquire the properties of another object usually child object from parent object.

SOURCE

https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)
Share:

Saturday, June 9, 2018

Which BASH internal variable holds the exit status of the previous command or function?

Which BASH internal variable holds the exit status of the previous command or function?

  • $?
  • $_
  • $@
  • $$ 

 
Which BASH internal variable holds the exit status of the previous command or function?

EXPLANATION

$? is a special variable that is internal to the BASH interpreter. It is used to hold the exit code of the previously executed command or function (or even the script itself).

Example:

#!/bin/bash

/bin/true
echo $? #prints 0

/bin/false
echo $? #prints 1

/bin/foobar
res=$?
if [ $res -ne 0 ]
then
  echo "Command foobar failed to execute or exited with a non-zero status: $res"
else
   echo "Command foobar exited successfully"
fi

Share:

Tuesday, May 22, 2018

In computing security, which of the following describes a nonce?

In computing security, which of the following describes a nonce?

  • A hacking algorythm
  • No Other non-Critical Events
  • A value used once
  • A vector 

 
In computing security, which of the following describes a nonce?

EXPLANATION

Typically, a nonce is some value that varies with time, although a very large random number is sometimes used. A nonce can be a time stamp, a visit counter on a Web page, or a special marker intended to limit or prevent the unauthorized replay or reproduction of a file.

SOURCE

http://searchsecurity.techtarget.com/definition/nonce
Share:

Friday, April 20, 2018

In PowerShell, which of the following is a feature that you use to assign a set of commands (optionally with input parameters) to execute by a single name?

In PowerShell, which of the following is a feature that you use to assign a set of commands (optionally with input parameters) to execute by a single name?

  • subroutine
  • procedure
  • function
  • method 

 
In PowerShell, which of the following is a feature that you use to assign a set of commands (optionally with input parameters) to execute by a single name?

EXPLANATION


In PowerShell, functions can act like miniature scripts within scripts which are executed by name, and they can be everything from a few commands, to full blown cmdlets written entirely in PowerShell (called Advanced Functions).
about_Functions on MSDN: https://msdn.microsoft.com/en-us/powershell/reference/4.0/microsoft.powershell.core/about/about_func...
about_Functions_Advanced on MSDN: https://msdn.microsoft.com/en-us/powershell/reference/4.0/microsoft.powershell.core/about/
Methods exist in PowerShell as well, as members of .NET objects: https://msdn.microsoft.com/en-us/powershell/reference/4.0/microsoft.powershell.core/about/about_meth...
Note: you can also access the above three directly in PowerShell with the commands:
Get-Help about_Functions
Get-Help about_Functions_Advanced
Get-Help about_Methods
Going beyond PowerShell, this is mostly a naming convention: the differences between the four names seem to vary from language to language.  While there are general technical definitions for each of the terms (for instance, "functions return a value; procedures do not"), these are not used universally among languages and programmers; as such, it's generally best to follow the naming convention common to the specific language.For more reading on the terms: http://softwareengineering.stackexchange.com/questions/20909/method-vs-function-vs-procedure

Share:

Monday, February 26, 2018

What happens when a volatile variable is declared in Java programming?

What happens when a volatile variable is declared in Java programming?

  • All reads and writes go straight to main memory
  • It holds a lock
  • It behaves as if enclosed in an asynchronous block
  • The value of the variable will be cached locally 

 
What happens when a volatile variable is declared in Java programming?

EXPLANATION

The Java volatile variable is an example of a special mechanism to guarantee that communication happens between threads. Basically, the value of the variable can be modified by different threads. When you declare a volatile variable, the value of this variable will never be cached thread-locally. Instead, all reads and writes will go straight to main memory. Access to the variable acts as though it is enclosed in a synchronized block, synchronized on itself.
Access to a volatile variable never has the potential to block because you can only ever do a simple read or write, so unlike a synchronized block it never holds on to any lock. Because of this, volatile variables are not suited for cases where you want to use read-update-write as an atomic operation, unless you are willing to miss an update. 

Share:

Monday, December 11, 2017

What logic construct most efficiently allows you to execute one of a number of code blocks based on the value of a single variable?

What logic construct most efficiently allows you to execute one of a number of code blocks based on the value of a single variable?

  • while
  • if
  • switch
  • for 

What logic construct most efficiently allows you to execute one of a number of code blocks based on the value of a single variable?

EXPLANATION

You can supply a variable to a "switch" statement, and provide a code block for each possible value.
Example using PowerShell:
switch ($var) {
    1 { <# Executes if $var = 1 #> }
    2 { <# Executes if $var = 2 #> }
    3 { <# Executes if $var = 3 #> }
    4 { <# Executes if $var = 4 #> }
    default { <# Executes if $var doesn't match any other case #> }
}
A single "switch" can take the place of a chain of "if/elseif/else".
"for" and "while" are both loops.



Share:

Thursday, November 23, 2017

What was the Java programming language originally named?

What was the Java programming language originally named?

  • Oak
  • Green
  • Mocha
  • Blue 
What was the Java programming language originally named?

 

EXPLANATION

"The language was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee."

Related: History of programming languages:

SOURCE

http://www.javaworld.com/article/2077265/core-java/so-why-did-they-decide-to-call-it-java-.html
Share:

Which of the following RegEx character sets does the '\w' meta-character most closely represent in Perl-compatible Regular Expression implementations?

Which of the following RegEx character sets does the '\w' meta-character most closely represent in Perl-compatible Regular Expression implementations?

  • [a-zA-Z]
  • [a-zA-Z0-9]
  • [a-zA-Z_]
  • [a-zA-Z0-9_] 

 
Which of the following RegEx character sets does the '\w' meta-character most closely represent in Perl-compatible Regular Expression implementations?

EXPLANATION

The "word" meta-character \w in RegEx will match the full alpha-numeric range, basically the full alphabet as well as number characters, and includes underscores.

Note that it matches more alphabet characters than the standard a through z: pretty much any alphabet character, such as 'ñ', also match.

http://www.w3schools.com/jsref/jsref_regexp_wordchar.asp 
Share:

In Perl, which variable contains the parameters passed to a subroutine?

In Perl, which variable contains the parameters passed to a subroutine?

  • $ARGV
  • $0 through $9
  • @_
  • @parameters 

 
In Perl, which variable contains the parameters passed to a subroutine?

EXPLANATION

The @_ array contains the parameters passed to any perl subroutine, method or function. You may reference the @_ array with either list assignment, e.g. "my ($param1, $param2) = @_;" or via referencing any of the array indicies, e.g. "my $param2 =  $_[1];".

SOURCE

https://stackoverflow.com/questions/4563485/what-is-the-meaning-of-in-perl
Share:

Which of the following is considered the first object-oriented programming language?

Which of the following is considered the first object-oriented programming language?

  • Java
  • Simula 67
  • C++
  • Smalltalk 

 
Which of the following is considered the first object-oriented programming language?

EXPLANATION




The formal programming concept of objects was introduced in the 1960's in Simula. The Simula 1 and later Simula 67 were programming languages designed for discrete event simulation/ jSijmula was created by Ole-Johan Dahl and Kristen Nygaard of the Norwegian Computing Center in Oslo/
https://en.wikipedia.org/wiki/Object-oriented_programming#History
https://en.wikipedia.org/wiki/Simula

SOURCE

https://en.wikipedia.org/wiki/Simula
Share:

In JavaScript, what is the result of the following: (true + false) > (2 + true);

In JavaScript, what is the result of the following: (true + false) > (2 + true);

  • false
  • TypeError
  • NaN
  • true 

 
In JavaScript, what is the result of the following: (true + false) > (2 + true);

EXPLANATION

The above line of JavaScript returns false. Why? The reason is called type coercion. You're using two boolean values in an arithmetic operation, which is not possible unless the interpreter converts them into numbers first. So consider the following:
If you evaluate the statements, you find that true equals 1 and false equals 0. So your expression is equivalent to:
(1 + 0) > 2 + 1
which reduces to:
1 > 3

which is false!

Share:

Wednesday, November 22, 2017

Which .NET RegEx pattern does NOT match the string "Tales from SpiceWorks!"?

Which .NET RegEx pattern does NOT match the string "Tales from SpiceWorks!"?

  • '^\w*\ \w* \w*\W$'
  • '^(?x)\w{5} \w{4} \w{10}!$'
  • '^[^bunz]*$'
  • '^(?:\w{4,10}\s?){3}\W$' 
Which .NET RegEx pattern does NOT match the string "Tales from SpiceWorks!"?

 EXPLANATION

'^(?x)\w{5} \w{4} \w{10}!$' does not match because it uses the RegEx option "x", which ignores unescaped white space; if you replaced the white space with "\s" or removed the "(?x)" option, it would work.


Share:

A directory entry on a Unix or Linux system includes which of the following?

In Windows, how do you enter ASCII characters that are not displayed on a keyboard?

  • Ctrl-Alt + keyboard keys cooresponding to ASCII
  • Alt + ASCII decimal value using keyboard top
  • Alt + ASCII decimal value on number pad
  • Shift-Alt + keyboard keys cooresponding to ASCII 

A directory entry on a Unix or Linux system includes which of the following?

EXPLANATION

I have used Alt + ASCI decimal value entered on the number pad for many years for various reasons.  It's a nice way to hide characters in passwords or files you want to keep secure. A password with an Alt-255 (null) character will display as a space and baffle even the most experienced hacker. While working in a public school system, my remote software client was VNC and it stored the password in hexidecimal format in the registry which above average students might possibly be able to decode. But when ASCII 255 characters are found, they're totally confused. I have also named programs and batch files with just the null character plus extension to make it hidden.  I have also used ASCII extended box and line characters to make things look nicer in batch programs, but is limited with newer versions of Windows that lack ANSI.sys not being standard (it can be enabled).
Share:

Regarding the well-known Commodore 64 BASIC V2 command [LOAD "*",8,1], which of the following is true?

Regarding the well-known Commodore 64 BASIC V2 command [LOAD "*",8,1], which of the following is true?

  • The 1 refers to the use the keyboard as input 1.
  • The 8 refers to the first disk drive.
  • $ and * are interchangeable.
  • LOAD can be abbreviated as Lo in this command. 
Regarding the well-known Commodore 64 BASIC V2 command [LOAD "*",8,1], which of the following is true?

 EXPLANATION

The device number 8 refers to the first disk drive. Device numbers range from 8-15 with 8 referencing the first disk drive. 9, the second disk drive, and so on.
The 1 is a secondary number and determines how the program will be loaded. 1 specifies that the program will be loaded absolute. 0 specifies that the program will be loaded to the start of BASIC memory.
The quoted symbol is the filename parameter. The * symbol will have the command load the first file. The $, load the disk directory.
The LOAD command can be abbreviated but not as Lo. Commodore BASIC shortcuts have a lowercase first letter and and capitalized second letter. The abbreviation lO (lower L, capital O) will work.
Sources
https://www.c64-wiki.com/index.php/LOAD
https://www.c64-wiki.com/index.php/BASIC_keyword_abbreviation

Share:

Which of the following programming languages does not treat the semicolon as a statement terminator?

Which of the following programming languages does not treat the semicolon as a statement terminator?

  • Java
  • Eiffel
  • C
  • Ada 
Which of the following programming languages does not treat the semicolon as a statement terminator?

 

EXPLANATION




In computer programming, the semicolon is often used to separate multiple statements (for example, in Perl, Pascal, PL/I, and SQL). In other languages, semicolons are called terminators and are required after every statement (such as in Java and the C family). Today, semicolons as terminators have largely won out, but this was a divisive issue in programming languages from the 1960s into the 1980s.

SOURCE

https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)
Share:

Tuesday, November 21, 2017

Which one of these is not a programming language?

Which one of these is not a programming language?

  • FooBar
  • J++
  • Scala
  • Lua 

 
Which one of these is not a programming language?

EXPLANATION


Foobar isn't a real programming language. J++ was a Microsoft variant of Java. You can see a list of programming languages here.
 
Share:

Popular Posts