Tag: programming languages
Questions Related to programming languages
class A { void m1(int i) { int j = i % 3; switch (j) { case 0: System.out.print("0"); break; case 1: System.out.print("1"); break; default: assert j == 2; System.out.print(j); }} public static void main (String[] args) { A a = new A(); for (int i=5; i >= -1; i--) {a.m1(i);} }} Which statements are true?
class C { String m1(int i) { switch (i) { case 0: return "A"; case 1: return "B"; case 2: return "C"; default: assert false; } } public static void main(String[] args) { C c = new C(); for (int i = 0; i < 4; i++) { System.out.print(c.m1(i)); }}} Which statements are true?
class C { int a, b, c; public void setA(int i) {a = i; assert validateC() : c;} public void setB(int i) {b = i; assert validateC() : c;} private boolean validateC() { return c > a + 2 * b; } public int m1(int i) { c = a + b + i; assert validateC() : c; return c; } public C(int i) { c = i; assert validateC() : c; } public static void main(String[] args) { C c = new C(251); c.setA(50); c.setB(100); }} Which statements are true?
What is the ouput of the following code snippet: $mystring = "[2004/04/13] The date of this article."; if($mystring =~ m/(\d)/) { print "The digit is $1"; }
What is the output of the follwing code snippet: $mystring = "The start text always precedes the end of the end text."; if($mystring =~ m/start(.*)end/) { print $1; }
What is the output of the following code snippet: $mystring = "[2009/02/14] The date of this article."; if($mystring =~ m/(\d+)/) { print "$1"; }
a\Sz
int (*p)(char *a)
int *p(void)