Computer Knowledge

Programming Fundamentals

2,611 Questions

Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.

Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references

Programming Fundamentals Questions

Multiple choice .net c-sharp
  1. Static

  2. Private

  3. Local

  4. Serial

  5. b and d

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To solve this question, the user needs to know the different types of variables that can be declared in Java and their scope.

Now, let's go through each option and explain why it is right or wrong:

A. Static: This option is incorrect because a static variable is a variable that is declared with the static keyword and belongs to the class, not to any instance of the class.

B. Private: This option is incorrect because a private variable is a variable that is declared with the private keyword and is only accessible within the class it is declared in.

C. Local: This option is correct. A local variable is a variable that is declared inside a method or block of code and has a scope that is limited to that method or block of code. The variable can only be accessed within the method or block of code it was declared in, and once the method or block of code is exited, the variable is destroyed.

D. Serial: This option is incorrect because there is no such thing as a "serial" variable in Java.

E. b and d: This option is incorrect because option d is invalid, and option b is incorrect because it describes a different type of variable than the one being asked for.

Therefore, the answer is: C. Local

Multiple choice .net c-sharp
  1. The result of a users action

  2. result of a party

  3. code to force users action

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To determine the correct answer, let's go through each option and explain why it is right or wrong:

A. The result of a user's action: This option is correct. An event is typically defined as the result of a user's action. In computer programming, an event can be triggered by user input, such as clicking a button or typing on a keyboard. The system responds to these actions by executing certain code or performing specific actions.

B. The result of a party: This option is incorrect. An event is not related to a party. In the context of computer programming, an event refers to user actions and their corresponding effects.

C. Code to force a user's action: This option is incorrect. An event is not code designed to force a user's action. Instead, events are typically triggered by user actions and are followed by specific reactions or responses from the system.

Therefore, the correct answer is A. The result of a user's action.

Multiple choice .net c-sharp
  1. reserved words

  2. method calls

  3. operator overloading

  4. operator overloading and method calls

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

String concatenation in C# supports both operator overloading (the + operator) and method calls (String.Concat, String.Join, StringBuilder.Append, etc.). You can write s1 + s2 or String.Concat(s1, s2) - both approaches are valid.

Multiple choice html
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The default case in a switch statement only executes when NO other case matches the expression being evaluated. It's an optional catch-all that runs if the switch value doesn't equal any of the defined case values. If a case matches and executes (with or without a break), the default is skipped.

Multiple choice javascript
  1. call function myFunction

  2. myFunction()

  3. call myFunction()

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To call a function named "myFunction", the user needs to use the following syntax:

myFunction();

Option A is incorrect because it is not the correct syntax for calling a function.

Option B is the correct answer because it calls the function "myFunction" using the proper syntax.

Option C is incorrect because it includes the word "call", which is not necessary when calling a function in most programming languages.

Therefore, the answer is: B. myFunction()

Multiple choice javascript
  1. var myarray = new Array();

  2. var myarray = array new;

  3. var new Array() = myarray;

  4. var new array = myarray;

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Arrays in JavaScript are created using the Array constructor with 'new' keyword. Option A shows the correct syntax: new Array(). Options B, C, and D incorrectly place keywords and variable names in the wrong order - they mix up the constructor name with the variable name.

Multiple choice javascript
  1. A method

  2. A function

  3. An operator

  4. A statement

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Void is an operator in JavaScript, not a method, function, or statement. It evaluates an expression and returns undefined. Option C is correct. Options A, B, and D incorrectly classify void as a method, function, or statement respectively.

Multiple choice javascript
  1. setTimeout("a["+i+"]",1000)

  2. k = a & i

  3. k = a(i)

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Option A demonstrates array syntax using bracket notation a[i] within setTimeout. Options B and C use incorrect syntax - the & operator is bitwise AND, not array access, and a(i) uses function call syntax instead of array indexing. Only option A properly uses JavaScript array notation.

Multiple choice javascript
  1. When you have multiple statements on multiple lines

  2. When you have multiple statements on a line

  3. When you have single statement on multiple lines

  4. When you have single statement on a line

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In many programming languages like C, Java, and JavaScript, semicolons act as statement terminators. While they often end lines, their primary structural necessity occurs when placing multiple distinct statements on a single line to help the compiler or interpreter distinguish between them.

Multiple choice perl
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Perl documentation and community usage, the terms 'function' and 'subroutine' (often shortened to 'sub') are used interchangeably to describe a named block of code that performs a specific task. While some languages distinguish between them based on return values, Perl does not.

Multiple choice php
  1. gettype()

  2. is_double()

  3. get_type()

  4. is_date()

  5. A&B

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

The gettype() function returns the type of a variable as a string (e.g., 'integer', 'string', 'array'). The is_*() family of functions like is_double(), is_int(), is_string() check if a variable is of a specific type, returning boolean true/false. Note that is_double() is an alias for is_float() - both check for floating-point numbers.

Multiple choice php
  1. ;

  2. #

  3. !

  4. %>

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

PHP instructions (statements) must be terminated with a semicolon (;), similar to many other programming languages like C, Java, and JavaScript. The semicolon tells the parser where the statement ends. This is required syntax in PHP - forgetting semicolons is a common syntax error.