programming languages Online Quiz - 13
Description: programming languages Online Quiz - 13 | |
Number of Questions: 20 | |
Created by: Aliensbrain Bot | |
Tags: programming languages |
How to check the version details in powershell 2.0?
What is the output for the below code ? class A implements Runnable{ public void run(){ System.out.println(Thread.currentThread().getName()); } } public class Test { public static void main(String... args) { A a = new A(); Thread t = new Thread(a); Thread t1 = new Thread(a); t.setName("t"); t1.setName("t1"); t.setPriority(10); t1.setPriority(-3); t.start(); t1.start(); } }
What is the output for the below code ? public class B { public String getCountryName(){ return "USA"; } public StringBuffer getCountryName(){ StringBuffer sb = new StringBuffer(); sb.append("UK"); return sb; } public static void main(String[] args){ B b = new B(); System.out.println(b.getCountryName().toString()); } }
What is the output for the below code ?import java.util.regex.Matcher;import java.util.regex.Pattern;public class Test { public static void main(String... args) { Pattern p = Pattern.compile("a*b"); Matcher m = p.matcher("b"); boolean b = m.matches(); System.out.println(b); }}
What is the output for the below code ? public class A { public A() { System.out.println("A"); } } public class B extends A implements Serializable { public B() { System.out.println("B"); } } public class Test { public static void main(String... args) throws Exception { B b = new B(); ObjectOutputStream save = new ObjectOutputStream(new FileOutputStream("datafile")); save.writeObject(b); save.flush(); ObjectInputStream restore = new ObjectInputStream(new FileInputStream("datafile")); B z = (B) restore.readObject(); } }
- public class Question { public static void main(String args[]) { int i=10; System.out.println("i="+++i); }
public class Question { public static void main(String args[]) { int x=010; System.out.print("X="+x); } }
public class Question { public static void main(String args[]) { int x=y=10; y=12; System.out.print(x+"&"+y); } }
public class e { public static void main(String args[]) { int i=3,j=2; System.out.print("i|j="+ (i|j)); } }
public class Question { public static void main(String args[]) { int x=0x10; System.out.print("X="+x); } }
Please dont Try this Question... Try Next One.... If you attend others, you will get to know the answer of this question. Questions: 1. 1. public class Question { Public static void main(String args[]) { int i=10; System.out.println("i="+++i); } 2. public class Question { public static void main(String args[]) { int x=010; System.out.print("X="+x); } } 3. public class Question { public static void main(String args[]) { int x=y=10; y=12; System.out.print(x+"&"+y); } } 4. public class Question{ public static void main(String args[]) { int i=3,j=2; System.out.print("i|j="+ (i|j)); } } 5. public class Question { public static void main(String args[]) { int x=0x10; System.out.print("X="+x); } } Answers: 1. System.out.println("i="+++i); Must be as a System.out.println("i="+ ++i); “Space between operators” 2. int x=010; In this statement, compile will take it as a OCTAL NUMBER. So OCTAL(10)=DECIMAL(8) 3. int x=y=10; In this statement, We are using y without declaring it. So will cause Compile Time Error. 4. 3 ? 1 1 2 ? 1 0 ------------------ (OR) 3 ? 1 1 5. int x=0x10; In the above statement, Compile will take it as a HEXA DECIMAL. So. HEXA(10) ? DECIMAL(16)
Which of the following class among these are synchronized?
String s = "India";String s2 = s;s.concat (” is a nation.”);System.out.println(s);
Is String class final?
What is the output of following.
public static void main(String[] args) {
final int b=3;
byte c=b/2;
System.out.println("c="+c);
}
What is the output of following.
public static void main(String[] args) {
String s1="prasad";
String s2="Ram";
s1.concat(s2);
System.out.println("c="+s1);
}
What is the output of following.
public static void main(String[] args) {
String s1="sanjay";
String s2="sanjay";
System.out.println("c="+s1==s2);
}
What is the output of following.
public static void main(String[] args) {
System.out.println("c="+args.length());
}