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 class
:
Content language: English
Русский
Which of the following methods are defined in the Object class?
Object class
What will happen when the following code is compiled and executed? 00: package test; 01: public class Test { 02: public static void main(String [] args) { 03: Test test = new Test(); 04: System.out.println(test.toString()); 05: } 06: }
Object class
If finalize() method is overridden in a class, when will this method called for an instance of that class?
Object class
What happens when the following code is compiled? public class Performer { public static void main(String[] args) { if (args instanceof Object) { // 1 System.out.println("yes"); } else { System.out.println("no"); } } }
Object class
Which of the following methods throws an exception InterruptedException?
Object class
Check all methods the Object class contains.
Object class
Which methods are defined in the Object class?
Object class
What will be shown in console after compiling this code: public class Test { public static void main(String[] args) throws Exception { Test test = new Test(); Test testCloned = (Test) test.clone(); Test test2 = test; boolean res = test.toString().equals(test2.toString()); boolean resClone = testCloned.toString().equals(test.toString()); System.out.println(res); System.out.println(resClone); } }
Object class
What will be the result of compilation and execution of the following code? public class Test { public static void main(String[] args) throws CloneNotSupportedException { A a1 = new A(); A a2 = (A) a1.clone(); System.out.println(a1 == a2); System.out.println(a1.min == a2.min); System.out.println(a1.max == a2.max); } } class A implements Cloneable { Integer min = new Integer(100); Integer max = new Integer(1000); @Override protected Object clone() throws CloneNotSupportedException { return super.clone(); } }
Object class
What will be the result of compilation and execution of the following code? public class Test { public static void main(String[] args) { TestClone t1 = new TestClone(); TestClone t2 = (TestClone) t1.clone(); for(int i = 0; i < t2.arr.length; i++) { t2.arr[i] = (t2.arr.length - i); } System.out.println(t1.arr.equals(t2.arr)); } } class TestClone implements Cloneable { int arr[] = {1, 2, 3, 4, 5}; public Object clone() { try { return super.clone(); } catch(CloneNotSupportedException e) { System.out.println("Clone not supported"); return this; } } }
Object class
← Prev
1
2
Next →
Sign Up Now
or
Subscribe for future quizzes