Searching for "variables"

Q:

All variables in PHP start with which symbol?

A) % B) !
C) $ D) &
 
Answer & Explanation Answer: C) $

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming
Exam Prep: Bank Exams

Q:

What do you mean by undeclared and undefined variables ?

Answer

Difference between undeclared and undefined variables is defined as


Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.


Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.

Report Error

View answer Workspace Report Error Discuss

Q:

Why static methods cannot access non static variables or methods?

Answer

A static method cannot access non static variables or methods because static methods doesnt need the object to be accessed. So if a static method has non static variables or non static methods which has instantiated variables they will no be intialized since the object is not created and this could result in an error.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

How would you check whether the contents of two structure variables are same or not?

Answer

struct emp


{


     char n[20];


      int age;


};


main()


{


    struct emp e1 = {"Dravid", 23};


   struct emp e2;


   scanf ("%s %d",e2.n, & e2.age);


   if( structcmp (e1,e2) ==0)


        printf ("The structures are equal");


   else


         printf ("The structures are unequal");


}


structcmp ( struct emp x, struct emp y)


{


     if (strcmp (x.n,y.n) ==0)


           if (x.age == y.age)


            return (0);


            return (1);


}


In short, if you nee to compare two structures, you'll have to write your own function to do so which carries out the comparison field by field.

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

Q:

Explain Superglobal variables in PHP .

Answer

To access the global data which is originating externally, the super globals are used. The superglobals are available as arrays. These superglobals represents the data from URLs, HTML forms, cookies, sessions and also the web server. For this purpose, $HTTP_GET_VARS, $HTTP_POST_VARS are used. The super globals are pretty good enough to be used in functions. The following are the list of super globals.


$_GET, $_POST, $_COOKIE;$_REQUEST, $_SERVER, $_SESSION, $_ENV, $_FILE


Another PHP Superglobal, called $GLOBALS; is available for persisting every variable with global scope.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

Q:

Mention the two major categories that distinctly classify the variables of C# programs.

Answer

Variables that are defined in a C# program belong to two major categories: value type and reference type. The variables that are based on value type contain a value that is either allocated on a stack or allocated in-line in a structure. The variables that are based on reference types store the memory address of a variable, which in turn stores the value and are allocated on the heap. The variables that are based on value types have their own copy of data and therefore operations done on one variable do not affect other variables. The reference-type variables reflect the changes made in the referring variables.

Report Error

View answer Workspace Report Error Discuss

Subject: .NET

Q:

Swap two variables without using third variable.

Answer

#include<stdio.h>
int main(){
    int a=5,b=10;
    a=b+a;
    b=a-b;
    a=a-b;
    printf("a= %d  b=  %d",a,b);
}

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

Q:

Inside an interface when should the variables be initialized?

A) Globally B) Whenever required
C) Inside a function D) During the time of declaration
 
Answer & Explanation Answer: D) During the time of declaration

Explanation:

They should be initialized during the time of declaration itself otherwise it is a compilation eror

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer