0

programming languages Online Quiz - 16

Description: programming languages Online Quiz - 16
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

What is the result of the following code? 1. public class Drink { 2. private int millis = 200; 3. boolean carbonated = false; 4. 5. public static void main(String [] args) { 6. System.out.println(new AppyFizz()); 7. } 8. } 9. class AppyFizz extends Drink { 10. public String toString() { 11. return millis + " " + carbonated; 12. } 13. }

  1. 12 false

  2. Compiler error on line 6

  3. Compiler error on line 12

  4. Compiler error on line 11


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) 12 false - This option is incorrect because the millis variable is not accessible in the AppyFizz class due to its private access modifier. Therefore, the code will not compile.

Option B) Compiler error on line 6 - This option is incorrect because there is no error on line 6. The code will compile without any issues.

Option C) Compiler error on line 12 - This option is incorrect because there is no error on line 12. The toString() method is overridden correctly in the AppyFizz class.

Option D) Compiler error on line 11 - This option is correct because the millis variable is declared as private in the Drink class and is not accessible in the AppyFizz class. Therefore, the code will not compile, resulting in a compiler error on line 11.

The correct answer is D. Compiler error on line 11. This option is correct because the millis variable is not accessible in the AppyFizz class, resulting in a compiler error.

What is the result of the following code? 1. public abstract class A { 2. private void doStuff() { 3. System.out.println("A"); 4. } 5. 6. public static void main(String [] args) { 7. A a = new B(); 8. a.doStuff(); 9. } 10. } 11. 12. class B extends A { 13. protected void doStuff() { 14. System.out.println("B"); 15. } 16. }

  1. A

  2. B

  3. Compiler error on line 7

  4. Compiler error on line 13


Correct Option: A

What is the result of the following code? 1. public abstract class Catchable { 2. protected abstract void catchAnObject(Object x); 3. 4. public static void main(String [] args) { 5. java.util.Date now = new java.util.Date(); 6. Catchable target = new MyStringCatcher(); 7. target.catchAnObject(now); 8. } 9. } 10. 11. class MyStringCatcher extends Catchable { 12. public void catchAnObject(Object x) { 13. System.out.println("Caught object"); 14. } 15. 16. public void catchAnObject(String s) { 17. System.out.println("Caught string"); 18. } 19. }

  1. Caught string

  2. Caught object

  3. Compiler error on line 12

  4. Compiler error on line 2


Correct Option: B

At Dartmouth College in 1964 John Kemeny and Thomas Kurtz invented .... ?

  1. ALGOL

  2. BASIC

  3. FORTRAN

  4. NONE


Correct Option: B

You could use XSLT to ...

  1. speed up database queries

  2. encrypt passwords

  3. transform XML into HTML

  4. cache html pages


Correct Option: C
  1. Anders Hejlsberg

  2. Grace Hopper

  3. Bjarne Stroustrup

  4. Alan Cooper


Correct Option: C

Which of these is not a functional programming language

  1. F#

  2. ERLANG

  3. LISP

  4. FORTRAN


Correct Option: D

AI Explanation

To answer this question, you need to understand the concept of functional programming languages. Functional programming languages are designed to treat computation as the evaluation of mathematical functions and avoid changing state and mutable data. Let's go through each option to understand why it is correct or incorrect:

Option A) F# - This option is incorrect because F# is a functional programming language developed by Microsoft that runs on the .NET framework.

Option B) ERLANG - This option is incorrect because Erlang is a functional programming language designed for concurrent, distributed, and fault-tolerant systems.

Option C) LISP - This option is incorrect because LISP (LISt Processing) is one of the oldest functional programming languages and is known for its use of linked lists as fundamental data structures.

Option D) FORTRAN - This option is correct because FORTRAN (FORmula TRANslation) is not a functional programming language. It is an imperative programming language primarily used for scientific and engineering computations.

The correct answer is D) FORTRAN. This option is correct because FORTRAN is not a functional programming language.

  1. web languages

  2. declarative languages

  3. functional languages

  4. visual languages


Correct Option: C

A true or false statement put into code that the programmer expects to always be true is an ...

  1. exception

  2. harness

  3. assertion

  4. expression


Correct Option: C

EBNF is ...

  1. Extensible Book Notation Format

  2. a replacement for the SAX XML parser

  3. the leader of the free software foundation

  4. a syntax for defining grammar


Correct Option: D

A section of code that responds to a particular interaction of the user with a gui control is called a ... ?

  1. dispatch function

  2. event handler

  3. control structure

  4. exception handler


Correct Option: B

RISC is ...

  1. a defensive programming style

  2. a web framework

  3. a threading library

  4. a CPU design strategy


Correct Option: D

I define 8 different methods, including CONNECT, PATCH, PUT and POST. I am stateless. I have a four letter name. What am I ?

  1. SFTP

  2. EFTP

  3. HTTP

  4. XSLT


Correct Option: C
Dim strQuestion,strCount
strQuestion=" abc " 
strQuestion=Trim(strQuestion) 
strCount=Len(strQuestion)
  1. strCount=7

  2. strCount=9

  3. strCount=3

  4. strCount=0


Correct Option: C

Dim strOne strOne=String(3,"A") Msgbox strOne

  1. aaa

  2. A A A

  3. AAA

  4. A


Correct Option: C

Dim strOne strOne=InStrRev("abc","ABC") Msgbox strOne

  1. 1

  2. 3

  3. 0

  4. 6


Correct Option: C

Dim x x=InStrRev("abc abc","abc") x=????

  1. x=2

  2. x=3

  3. x=5

  4. x=0


Correct Option: C
x="TIB Ltd"  
y=Len(x)
y=???
  1. 7

  2. 6

  3. 3

  4. 0


Correct Option: A

x=Right("abcd.xls",4) x=????

  1. .xls

  2. abcd

  3. excel

  4. true


Correct Option: A
- Hide questions