programming languages Online Quiz - 17
Description: programming languages Online Quiz - 17 | |
Number of Questions: 20 | |
Created by: Aliensbrain Bot | |
Tags: programming languages |
The statement that is used to replace multiple if statements is
The following code will generate a compiler error.
string GetAgePhrase(int age) { if (age > 60) return "Senior"; if (age > 40) return "Middle-aged"; if (age > 20) return "Adult"; if (age > 12) return "Teen-aged"; if (age > 4) return "Toddler"; }
Which of the following statements, inserted as the last line of the function, would solve the problem?
static void Main(string[] args) { try { Console.WriteLine("Level 1"); try { Console.WriteLine("Level 2"); goto exit; } finally { Console.WriteLine("Level 2 Finished"); } } finally { Console.WriteLine("Level 1 Finished"); } exit: ; }
What is the output?
what is the default access specifier for a Top-level Class, which are not nested into other Classes?
Which statement is true about interface and abstract classes?
If a method is marked as protected internal who can access it?
The default type of enum is integer and has a default value 1.
Unboxing of a null refrence type will return null.
can we have protected element as a namespace member? eg namespace mine { protected class test { } }
Can multiple catch blocks be executed for single try block?
Difference between const and readonly
A variable declared inside a method is called
In programming languages, which language's version name is also known as "Scorpio" ?
The following code contains a compilation error , what can be done to fix this error – independently?
abstract class AirPlane { // line 1 abstract void fly(); // line 2 void land() { System.out.print("Landing.."); } } class AirJet extends AirPlane { // line 10 AirJet() { super(); // line 13 } void fly() { System.out.print("Flying.."); } abstract void land(); // line 20 }
Please choose all the answers that apply:
a) Remove abstract from line 20 and add body to method land()
b) Declare class AirJet as abstract to at line 10
c) Remove super() call at line 13
d) Remove abstract at line 1 and line 2
What are the rules to implement an interface? Considering the following declaration for interface Convertable, which of the following code segments will compile?
public interface Convertable { int convertToInt(); char convertToChar(); }
a)
class Digit implements Convertable { public char convertToChar() { return 0; } public int convertToInt() { return 0; } }
b)
abstract class Digit implements Convertable { int convertToInt(); char convertToChar(); }
c)
abstract class Digit implements Convertable { public int convertToInt() { return 0; } }
d)
abstract class Digit implements Convertable { public int convertToInt() { return 0; } char convertToChar(); }
e)
class Digit implements Convertable { int convertToInt() { return 0; return 0; } }
f)
interface Roundable extends Convertable { int roundUp(); }
Which of the following variables is incorrectly declared?
public abstract interface Bouncable { int a = 0; public int b = 1; public static int c = 2; public static transient int d = 3; public final int e = 3; public static final int f = 3; }
Three of the methods are incorrectly declared, which are they?
public abstract class Tester { public void test1(); public final void test2() {}; public static void test3() {}; public abstract static void test4(); public abstract final void test5(); }
Is the following declaration for interface Bendable correct and free of compilation error?
abstract interface Bendable { // line 1 final int x = 2009; // line 3 void method1() {}; // line 5 }
What is the result of compiling and running the following code?
public class Tester { public static void main(String[] args) { System.out.print("1"); try { return; } catch (Exception e) { System.out.print("2"); } finally { System.out.print("3"); } System.out.print("4"); } }