Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
object reference
:
Content language: English
Русский
What happens when you try to compile and run this code: 00: public class Test { 01: public static void main(String[] args) { 02: Object obj = new String("String object"); 03: String str = (String) new Object(); 04: System.out.println(obj); 05: System.out.println(str); 06: } 07: }
object reference
What will be printed by the following code? public class Test { static Boolean bo1 = new Boolean("true"); static Boolean bo2 = new Boolean(false); public static void main(String[] args) { Boolean bo3 = new Boolean(bo1); Boolean bo4 = new Boolean("bo2"); System.out.println(bo1.equals(bo3)); System.out.println(bo2.equals(bo4)); } }
object reference
What happens at compile-time and running of the following code? public class Test { public static void main(String[] args) { String s1 = new String("string"); String s2 = new String("STRINg"); StringBuilder sb1 = new StringBuilder("test"); StringBuilder sb2 = new StringBuilder("test"); System.out.println(s1.equalsIgnoreCase(s2) && sb1.equals(sb2) && s2.charAt(s2.length()) == 'g'); } }
object reference
What will be the result of the following code: import java.util.*; public class Test { public static void main(String[] args) { Class c1 = new ArrayList<String>().getClass(); Class c2 = new ArrayList<Integer>().getClass(); System.out.println(c1 == c2); } }
object reference
Select one right option of compiling and running this code. public class Strings { public static void main(String[] args) { String s1 = new String("Bicycle"); String s2 = new String("bicycle"); System.out.println(s1.equals(s2) == s2.equals(s1)); } }
object reference
What is the result of compiling and running the following code? class Base { public String name = "Base"; public String getName() { return name; } } class Sub extends Base { public String name = "Sub"; public String getName() { return name; } } public class Program { public static void main(String[] args) { Sub s = new Sub(); Base b = s; System.out.println(b.name); } }
object reference
What will be printed as a result of this code? import java.util.Arrays; class ArraysComparing { public static void main(String...args) { int[] i1[] = {{1,2,3}, {0,0,0}}; int[][] i2 = {{1,2,3}, {0,0,0,}}; int[][] i3 = new int[2][3]; System.arraycopy(i1, 0, i3, 0, i3.length); System.out.println(Arrays.equals(i1, i2)); System.out.println(Arrays.equals(i1, i3)); System.out.println(Arrays.deepEquals(i1, i2)); } }
object reference
What will be the result of the following code execution? import java.util.*; class Employee { private String name; public Employee(String name) { this.name = name; } public String toString() { return name; } public boolean equals(Object obj) { HashCodeTest.count++; if (obj == null) return false; if (obj.getClass() != getClass()) return false; Employee emp = (Employee) obj; if (this.name == emp.name) { return true; } return false; } public int hashCode(){ return name.hashCode(); } } public class HashCodeTest { static int count = 0; public static void main(String[] args) { Map employees = new HashMap(); employees.put(new Employee("Joe"), new Integer("1")); employees.put(new Employee("Chandler"), new Integer("2")); employees.put(new Employee("Chandler"), new Integer("2")); employees.put(new Employee("Ross"), new Integer("3")); Iterator iterator = employees.keySet().iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } System.out.println(count); } } P.S. For experts - hashtags of the lines "Joe", "Chandler" and "Ross" are different.
object reference
From which data structure will the "garbage collector" remove all items in which last reference to the key in this structure has disappeared?
object reference
← Prev
1
Next →
Sign Up Now
or
Subscribe for future quizzes