Wednesday 24 June 2020

Blog Posting



अगर आप अपना कोई ब्लॉग इस www.tgtpgtcs.com वेबसाइट पर लिखना या पोस्ट करवाना चाहते हैं तो अच्छी फॉर्मेटिंग के साथ एमएस वर्ड फाइल में अपना ब्लॉग लिखकर हमें ईमेल करें ईमेल में अपना नाम मोबाइल नंबर ईमेल आईडी और एड्रेस भी लिखें हमारी ईमेल आईडी support@spsharmag.com है

Tuesday 23 June 2020

29 - Web Designing Question - 09


 

What is the correct statement when declaring and assigning the value of 100 to an integer variable called numPeople in Visual Basic?

(A)    Dim numPeople =100

(B)    Dim numPeople = Int (100)

(C)    numPeople = 100

(D)   Dim numPeople As Integer = 100


Variable Declaration in VB.Net

The Dim statement is used for variable declaration and storage allocation for one or more variables. The Dim statement is used at module, class, structure, and procedure or block level.

Some valid variable declarations along with their definition are shown here –

Dim StudentID As Integer

Dim StudentName As String

Dim Salary As Double

Dim count1, count2 As Integer

Dim status As Boolean

Dim exitButton As New System.Windows.Forms.Button

Dim lastTime, nextTime As Date

Variable Initialization in VB.Net

Variables are initialized (assigned a value) with an equal sign followed by a constant expression. The general form of initialization is −

variable_name = value;

For example,

Dim pi As Double

pi = 3.14159

You can initialize a variable at the time of declaration as follows −

Dim StudentID As Integer = 100

Dim StudentName As String = "Ram"

 

 

So here correct answer is option (D) i.e.

Dim numPeople As Integer = 100 

28 - Web Designing Question - 08


Which plugin is used to cycle through elements, like a slideshow?

(A)    Orbit

(B)    Slideshow

(C)    Scrollspy

(D)   Carousel



The carousel is a slideshow plug-in of Bootstrap framework for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators.

 

You can create slideshow using carousel for details you can visit on this link

 



So Correct Answer is option (D) 

27 - Web Designing Question - 07

Which of the following Visual Basic statement will assign the value "QUICK" from the variable y to the string variable x?

Y= "The QUICK RED FOX JUMPED OVER THE DOG"

(A)    x= Middle (y, 5, 5)

(B)    x= left (Y,5)

(C)    x= Mid (Y,5,5)

(D)   x= Instr (5,y, "QUICK") 


 

Option (A)

There is no function in VBScript of name Middle. So it is wrong

Option (B)

Left(string, no_of_char) is a text function use to extract the chars or string form the left of main string. For example

Left(“Ram Kumar”,3) will return Ram

So it is not a correct answer because we want extract chars from middle.

Option (C)

For extract chars from the middle of a string we use mid() function in VBScript

Mid(string, start, no_of_char)

Here string is the main string from which we want to extract chars

Start is the starting position from which we want to extract chars

No_of_char represent the how many chars we want to extract from the string

Mid(Y,5,5) return “QUICK” because position of Q is 5 and There are five characters in QUICK

So it is the correct Answer

Option (D)

Instr (5,y, "QUICK") is a text function it return the first occurrence of QUICK checking from 5th position so it return 5


26 - Web Designing Question - 06


Among the keywords below, which one is not a statement?

(A)    if

(B)    with

(C)    debugger

(D)   use strict


Here if, with and debugger are used in java script statement whereas “use strict” is not use in the statement.

use strict is a directive introduced in ECMAScript5. Directives are not statements because it does not include any language keywords. Also, it can appear only at the start of a script or at the start of a function body, before any real statement have appeared.

 

How to use the 'use strict' keyword in JavaScript?

1.      "use strict"; Defines that JavaScript code should be executed in "strict mode".

2.      It prevents you from using undeclared variables. It is like “option explicit” in VBScript.

3.      When we use “use strict” it is necessary to declare a variable before use.

4.      Strict mode is declared by adding "use strict"; to the beginning of a script or a function.

Declared at the beginning of a script, it has global scope

"use strict";

x = 3.14;       // This will cause an error because x is not declared

 

"use strict";

myFunction();


function myFunction() {

  y = 3.14;   // This will also cause an error because y is not declared

}

 

x = 3.14;       // This will not cause an error.

myFunction();


function myFunction() {

  "use strict";

  y = 3.14;   // This will cause an error

}

 

Deleting a variable (or object) is not allowed.

 

"use strict";

var x = 3.14;

delete x;                // This will cause an error

 

Deleting a function is not allowed.

 

"use strict";

function x(p1, p2) {};

delete x;                // This will cause an error 

 

Duplicating a parameter name is not allowed:

"use strict";

function x(p1, p1) {};   // This will cause an error

 

Octal numeric literals are not allowed:

"use strict";

var x = 010;             // This will cause an error

 

How to use the 'with' keyword in JavaScript?

The with keyword is used as a kind of shorthand for referencing an object's properties or methods.

The object specified as an argument to with becomes the default object for the duration of the block that follows. The properties and methods for the object can be used without naming the object.

Syntax

The syntax for with object is as follows −

with (object){

   properties used without the object name and dot

}

JavaScript's with statement was intended to provide shorthand for writing recurring accesses to objects.

So instead of writing

a.b.c.d.e.f.name=”ram”

a.b.c.d.e.f.age=25

You can write

with (a.b.c.d.e.f) {

    name=”ram”;

    age=25

}

 

JavaScript debugger Statement

1.      The debugger statement stops the execution of JavaScript, and calls (if available) the debugging function.

2.      Using the debugger statement has the same function as setting a breakpoint in the code.

3.      Normally, you activate debugging in your browser with the F12 key, and select "Console" in the debugger menu.

Note: If no debugging is available, the debugger statement has no effect.

Syntax

debugger;

 

var x = 15 * 5;

debugger;

document.getElementById("demo").innerHTML = x;

 

You all know about If statement. So here we are not discussing about if.

So Answer of this question is option (D) use strict 

25 - Web Designing Question - 05


Which statement will send the value generated by a function procedure, called CalculateTax, back to the calling code in Visual Basic?

(A)    Return Sales*0.08

(B)    CalculateTax = Sales*0.08

(C)    Return CalculateTax (Sales*0.08)

(D)   Both A and B



 

Using Return Sales*0.08

Function CalculateTax(Sales)

Return Sales*0.08

End Function

 

dim total_tax as Double

total_tax = CalculateTax(5000)

MessageBox.Show("Total Tax=" & total_tax & "<br/>")

 

 

Output is

Total Tax=400

 

 

Using CalculateTax = Sales*0.08

Function CalculateTax(Sales)

CalculateTax = Sales*0.08

End Function

 

dim total_tax as Double

total_tax = CalculateTax(5000)

MessageBox.Show("Total Tax=" & total_tax & "<br/>")

 

 

Output is

Total Tax=400

 

So Ans is (D)   Both A and B


24 - Web Designing Question - 04


In VBScript, function can return multiple values

(A)    Yes

(B)    No

A VBScript function can have an optional return statement. This is required if you want to return a value from a function. For example, you can pass two numbers in a function and then you can expect from the function to return their multiplication in your calling program.

NOTE − A function can return multiple values separated by comma as an array assigned to the function name itself.

Example

This function takes two parameters and concatenates them and returns result in the calling program. In VBScript, the values are returned from a function using function name. In case if you want to return two or more values, then the function name is returned with an array of values. In the calling program, the result is stored in the result variable.

Return a single value from a function

<script language = "vbscript" type = "text/vbscript">

         Function concatenate(first, last)

            Dim full

            full = first & last

            concatenate = full  'Returning the result to the function name itself

         End Function

         ' Here is the usage of returning value from  function.

         dim result

            result = concatenate("Zara", "Ali")

        msgbox(result)

      </script>

 

 

 Return multiple values from a function

 

<script type="text/vbscript">

Function func(a, b)

mul=a*b

div=a/b

m=a+b

n=a-b

func = Array(mul,div,m,n)

End Function

 

dim val

val = func(3,4)

document.write("mul=" & val(0) & "<br/>")

document.write("div=" & val(1) & "<br/>")

document.write("add=" & val(2) & "<br/>")

document.write("sub=" & val(3) & "<br/>")

</script>

 

Output

mul=12
div=0.75
add=7
sub=-1

 



So Answer is (A) Yes 

23 - Web Designing Question - 03

The Rnd statement will generate a(n)?

(A)    decimal value between 0.01 and 1.00

(B)    integer value between 0.01 and 1.00

(C)    decimal value between 0.0 and 1.0

(D)   decimal value between 0.0 and up to 1.0, but not including 1.0



The Rnd function returns a random number. The number is always less than 1 but greater or equal to 0.

Syntax

Rnd[(number)]

Number is an optional parameter

If number is:

<0 - Rnd returns the same number every time

>0 - Rnd returns the next random number in the sequence

=0 - Rnd returns the most recently generated number

Not supplied - Rnd returns the next random number in the sequence

 

<script type="text/vbscript">

document.write(rnd(0) & "</br>")

document.write(rnd(5) & "</br>")

document.write(rnd(0.5) & "</br>")

document.write(rnd() & "</br>")

</script>

  

So Ans is 
(D)   decimal value between 0.0 and up to 1.0, but not including 1.0
 

22 - Python Question Discussion - 05


How to create a list of lists where each sub-list 'increments' as follows: [1, 0, 0], [1, 1, 0], [1, 1, 1] [closed]


21 - Python Question Discussion - 04

Why does Python3 produce this output?

 

>>>True, True, True == (True, True, True)

True, True, False

 

>>True == (True, True)

False

 

>>True == (True)

True