Computer Knowledge

Programming Languages and Compilers

2,284 Questions

Programming languages and compilers involve the rules, syntax, and semantics used to write and execute software programs. Key areas include scripting languages, object oriented concepts, and parsing algorithms like top down parsers. Practice these computer science questions to build proficiency for technical and computer knowledge exams.

Object oriented languagesScripting languagesCompilers and parsersProgramming syntax

Programming Languages and Compilers Questions

Multiple choice java
  1. class, if, void, long, Int, continue

  2. goto, instanceof, native, finally, default, throws

  3. try, virtual, throw, final, volatile, transient

  4. strictfp, constant, super, implements, do

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

All the words in option B are among the 49 Java keywords. Although goto reserved as a keyword in Java, goto is not used and has no function.Option A is wrong because the keyword for the primitive int starts with a lowercase i.Option C is wrong because "vi

Multiple choice c
  1. gets( s[100] );

  2. gets( s[] );

  3. gets( s );

  4. none of the above

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

The function gets() expects a pointer to a character array (char *). Since the array name s decays to a pointer to its first element, gets(s) is the correct syntax. Option A passes an int, and B uses invalid empty bracket syntax.

Multiple choice php
  1. Using a for loop

  2. Using a foreach loop

  3. Using a while loop

  4. Using a do..while loop

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

To modify array elements during iteration in older PHP versions, a 'for' loop using the index is safest. While 'foreach' can use references (&$value) in newer PHP, the 'for' loop directly accesses the original array index, ensuring the modification persists without reference-related side effects.

Multiple choice php
  1. print() can be used as part of an expression, while echo() can't

  2. echo() can be used as part of an expression, while print() can't

  3. echo() can be used in the CLI version of PHP, while print() can't

  4. print() can be used in the CLI version of PHP, while echo() can't

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

In PHP, print() returns a value (1), allowing it to be used in expressions (e.g., if (!print('a'))). echo() does not return anything and outputs the string directly, making it invalid within complex expressions requiring a return value.

Multiple choice php
  1. show_errors, enable

  2. show_errors, show

  3. register_globals, enhance

  4. register_globals, inject

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

The 'register_globals' directive (deprecated and removed in modern PHP) automatically created global variables from EGPCS (Environment, GET, POST, Cookie, Server) variables. This 'injected' user-provided data directly into the script's global scope, creating significant security vulnerabilities.

Multiple choice php
  1. print substr($text, strchr($text, ':'));
  2. print substr($text, strchr($text, ':') 1);
  3. print substr($text, strpos($text, ':') 1);
  4. print substr($text, strpos($text, ':') 2);
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The string is assumed to be 'Content-Type: text/xml'. Option D uses strpos to find the colon at index 13, then adds 2, skipping the colon and space to start at 't'. The output would be 'text/xml'. Option C only adds 1 (starts with space). Option A uses strchr which returns the rest of the string.

Multiple choice .net
  1. VB.NET

  2. VB 6

  3. C++

  4. C#

  5. Java

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

To determine the language that is not a true object-oriented programming language, we need to understand the concept of object-oriented programming and the characteristics that define it.

Object-oriented programming (OOP) is a programming paradigm that uses objects, which are instances of classes, to represent and manipulate data. Key features of OOP include encapsulation, inheritance, and polymorphism.

Now let's go through each option and determine if it is a true object-oriented programming language:

A. VB.NET: VB.NET is a true object-oriented programming language. It is an evolution of Visual Basic and fully supports OOP concepts.

B. VB 6: VB 6, also known as Visual Basic 6, is not a true object-oriented programming language. While it has some object-oriented features, such as support for classes and objects, it lacks full support for OOP concepts like inheritance and polymorphism.

C. C++: C++ is a true object-oriented programming language. It supports all the key features of OOP, including encapsulation, inheritance, and polymorphism.

D. C#: C# is a true object-oriented programming language. It was specifically designed for the Microsoft .NET framework and fully supports OOP concepts.

E. Java: Java is a true object-oriented programming language. It was designed to be purely object-oriented and supports all the key features of OOP.

Based on the explanations above, the language that is not a true object-oriented programming language is:

B. VB 6

The Answer is: B

Multiple choice .net
  1. btn and chb

  2. btn and cbo

  3. bto and chb

  4. bto and cbo

  5. cmd and cbo

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

To solve this question, the user needs to be familiar with common naming conventions for controls in user interfaces. Specifically, the user should know the standard prefixes used for button and combo box controls.

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

A. btn and chb: This option is incorrect. The prefix "btn" is commonly used for button controls, but the prefix "chb" is not typically used for combo box controls.

B. btn and cbo: This option is correct. The prefix "btn" is commonly used for button controls, and the prefix "cbo" is commonly used for combo box controls.

C. bto and chb: This option is incorrect. Neither the prefix "bto" nor the prefix "chb" are commonly used for button or combo box controls.

D. bto and cbo: This option is incorrect. The prefix "bto" is not commonly used for button controls, and the prefix "cbo" is commonly used for combo box controls.

E. cmd and cbo: This option is incorrect. The prefix "cmd" is not commonly used for button controls, and the prefix "cbo" is commonly used for combo box controls.

The correct answer is:

B. btn and cbo

Multiple choice .net
  1. Click

  2. SingleClick

  3. DoubleClick

  4. MouseMove

  5. MouseDown

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

Common control events include Click, DoubleClick, MouseMove, and MouseDown. 'SingleClick' is not a standard event name - the standard event is 'Click' which handles single clicks.

Multiple choice .net
  1. Const Form As Integer

  2. Const myForm As Integer

  3. Dim Form As Integer

  4. Dim myForm As Integer

  5. All of the above.

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

Both Const (for constants) and Dim (for variables) are valid statements for declaring entities. The naming rules are the same for both - 'Form' is a reserved keyword but 'myForm' is not, making B and D valid. Therefore all declarations shown are syntactically correct.

Multiple choice .net
  1. Abs

  2. CDbl

  3. Int

  4. Val

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

To solve this question, you need to know about the different functions in programming that are used to convert strings into numbers.

A. Abs - This function returns the absolute value of a number. It doesn't convert a string to a number.

B. CDbl - This function in Visual Basic (and some other programming languages) converts a string to a Double data type, which is a type of floating point number. This would be able to convert the string "\$56.7" to the number 56.7.

C. Int - This function converts number a to an integer. It doesn't convert a string to a number.

D. Val - This function in Visual Basic (and some other programming languages) returns the numbers found in a string. It would also be able to convert the string "\$56.7" to the number 56.7, but it would stop at the first non-numeric character, so it wouldn't handle the dollar sign correctly.

So, the correct answer is:

B. CDbl

Multiple choice .net
  1. MsgBox

  2. InputBox

  3. TextBox

  4. Both a and b.

  5. All of the above.

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

The function that displays a pop-up window in VBA is the MsgBox function. This function is used to display a message in a dialog box and can include buttons for the user to click.

Option A) MsgBox - This option is correct because this function displays a pop-up window. Option B) InputBox - This option is incorrect because this function displays an input box to prompt the user for input. Option C) TextBox - This option is incorrect because this is a control used to display or enter text in a user form. Option D) Both a and b - This option is incorrect because option B is incorrect. Option E) All of the above - This option is incorrect because option C is incorrect.

Therefore, the correct answer is option A, MsgBox.

Multiple choice .net
  1. It can be made of multiple values concatenated into one string.

  2. It can include the vbCrLf constant.

  3. It can include the ampersand symbol to concatenate strings.

  4. Both a and b.

  5. All of the above.

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

The correct answer is E. All of the above.

The prompt argument in VBA can be made of multiple values concatenated into one string. For example, the following code will display a prompt that says "Enter your name and age:":

prompt = "Enter your name and age:" & vbCrLf & "Name: " & _ vbTab & "Age: "

The prompt argument can also include the vbCrLf constant, which represents a carriage return and line feed. This will cause the prompt to be displayed on two separate lines.

Finally, the prompt argument can include the ampersand symbol to concatenate strings. For example, the following code will display a prompt that says "Your name is: [name]":

prompt = "Your name is: "& name

Therefore, all of the options A, B, and C are true about the prompt argument.

Here is a breakdown of the options:

  • Option A: The prompt argument can be made of multiple values concatenated into one string. This is true because the prompt argument is a string, and you can concatenate strings together using the ampersand symbol.
  • Option B: The prompt argument can include the vbCrLf constant. This is true because the vbCrLf constant represents a carriage return and line feed, and you can include any character or string in the prompt argument.
  • Option C: The prompt argument can include the ampersand symbol to concatenate strings. This is true because the ampersand symbol is used to concatenate strings together, and you can use it in the prompt argument.

Therefore, the correct answer is E. All of the above.

Multiple choice .net
  1. use the Val function to convert the Text value.

  2. use the CDbl function to convert the Text value.

  3. use the IsNumeric function to convert the Text value.

  4. Both a and b.

  5. All of the above.

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

To process a number typed in a TextBox, the programmer must convert the Text value to a numeric data type. This is necessary because the Text property of a TextBox control returns a string value, which cannot be used in mathematical operations without first being converted.

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

A. use the Val function to convert the Text value: This option is partially correct. The Val function is one way to convert a string to a numeric data type, but it is not the only way. The Val function converts a string to a Double data type, so it may not be appropriate if the value in the TextBox is an Integer.

B. use the CDbl function to convert the Text value: This option is partially correct. The CDbl function is another way to convert a string to a numeric data type, but it is not the only way. The CDbl function converts a string to a Double data type, so it may not be appropriate if the value in the TextBox is an Integer.

C. use the IsNumeric function to convert the Text value: This option is incorrect. The IsNumeric function does not convert a string to a numeric data type. Instead, it checks whether a value is numeric and returns a Boolean value.

D. Both a and b: This option is correct. Using either the Val or CDbl function can convert a string to a numeric data type. However, the programmer should choose the appropriate function depending on the data type of the value in the TextBox.

E. All of the above: This option is incorrect. While options A and B are correct, option C is not a valid way to convert a string to a numeric data type.

Therefore, the answer is: D. Both a and b.