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
casting
:
Content language: English
Русский
What is the result of the following code compilation and execution? public class Test { public static void main(String[] args) { float f = 1.0 + 1.0f; f = f + 1; System.out.println(f / 0); } }
casting
The following string variable is defined: String s = "abc"; Which of the following operations are allowed?
casting
What is the result of the following code execution: public class MainClass { public static void main(String args[]){ System.out.println((-(byte)128)>>>1 == 128 >>> 1); } }
casting
What will happen as a result of compiling and running the following code? class A { int i = 0; public int increment() { return ++i; } } public class B extends A { int i = 1; // 1 public int increment() { return ++i; } public static void main(String[] args) { B b = (B) new A(); // 2 System.out.println(b.increment()); } }
casting
What will be displayed? class A { int i = 0; public int increment() { return ++i; } } public class B extends A { int i = 10; public int increment() { return ++i; } public static void main(String[] args) { A obj = (A) new B(); System.out.println(obj.increment()); } }
casting
Given the program fragment: double p = Double.POSITIVE_INFINITY; double n = Double.NEGATIVE_INFINITY; System.out.println( ((long) p > (long) n) + " " + ((int) p > (int) n) + " " + ((short) p > (short) n) + " " + ((char) p > (char) n) + " " + ((byte) p > (byte) n)); What will be printed when this code is executed?
casting
Given the following two classes: public class Parent { protected int i; public Parent() { i = 1; } } public class Child extends Parent { private int i; public Child() { this.i = ((Child)new Parent()).getI(); this.i = this.i++ + ++super.i; } public int getI() { return i; } } What will be the output of the following code? public class Test { public static void main(String[] args) { Child c = new Child(); System.out.println(c.getI()); } }
casting
What will be the result of compilation and execution of the following code using JDK7 or newer? public class Main { public static void var(Integer x, int y) { System.out.println("Integer int"); } public static void var(Object... x) { System.out.println("Object"); } public static void var(int... x) { System.out.println("int... x"); } public static void var(Integer... x) { System.out.println("Integer..."); } public static void main(String... args) { byte i = 0; Integer i2 = 127; var(i, i2); } }
casting
What will be the result of compilation and execution of the following code? public class Test { public static void main(String[] args) { Double d = 1.56D; Long l = 257L; byte b = 10; System.out.println(d.longValue() + l.byteValue() + b % 2); } }
casting
← Prev
1
Next →
Sign Up Now
or
Subscribe for future quizzes