Select correct options to describe the following code: public class R4RSCJPTest { public int getSize() { return size; } public void setSize(int s) { size = s; } public int size; },Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher
Select correct options to describe the following code:
public class R4RSCJPTest 
{
      public int getSize() 
      {
            return size;
      }
      public void setSize(int s) 
      {
            size = s;
      }
      public int size;
}

More interview questions and answers

Exception Hierarchy

Handling an Entire Class Hierarchy of Exceptions

Exception Matching

Exception Declaration and the Public Interface

Rethrowing the Same Exception

Creating an Exception

Working with the Assertion Mechanism

Assertions Overview

Assertion Expression Rules

Enabling Assertions

Compiling with Assertions

Compiling Assertion-Aware Code

Compiling with Code That Uses Assert as an Identifier

Running with Assertions

Enabling Assertions at Runtime

Disabling Assertions at Runtime

Selective Enabling and Disabling

Using Assertions Appropriately

Do not use assertions to validate arguments to a public method.

Do use assertions to validate arguments to a private method.

Do not use assertions to validate command-line arguments.

Do use assertions, even in public methods, to check for cases that you know are never, ever supposed to happen

Do not use assert expressions that can cause side effects!

Select correct option for the following code: public class Vehicle { // Write here Vehicle code } public class Bike extends Vehicle { // Write here Cool Bike code } public class Hayabusa extends Bike { // Write here some specific information of Hayabusa // Keep in mind Hayabusa inherits accessible Bike members }

Which is the correct object-oriented relationship between a Building and a Apartment.

Select the three correct option in case of Method overriding.

Select two correct options from the followings:

Select three correct options from the followings:

What result comes when we compile and run following code: class Vehicle { } class Bike extends Vehicle { } class TestVehicles { public void ABC(Vehicle v) { System.out.println("Vehicle"); } public void ABC(Bike b) { System.out.println("Bike"); } public static void main (String [] args) { TestVehicles uvobj = new TestVehicles(); Vehicle vObj = new Vehicle(); Bike bObj = new Bike(); uvobj.ABC(vObj); uvobj.ABC(bObj); } }

What result comes when we compile and run following code: class Vehicle { } class Bike extends Vehicle { } class TestVehicles { public void ABC(Vehicle v) { System.out.print("Vehicle"); } public void ABC(Bike b) { System.out.println(" Bike"); } public static void main (String [] args) { TestVehicles uvobj = new TestVehicles(); Vehicle vObj = new Vehicle(); Vehicle VRTB = new Bike(); //VRTB(Vehicle refer to Bike) uvobj.ABC(VRTB); } }

Given the following, public class myprog { final static short a = 2; public static in b = 0; public static void main(String [] args) { for (int c=0; c < 3; c++) { switch (c) { case b: System.out.print("0 "); case a-1: System.out.print("1 "); case a: System.out.print("2 "); } } } } what is the result ?

Given the following, public class myprog { final static short a = 2; public static int b = 0; public static void main(String [] args) { for (int c=0; c < 3; c++) { switch (c) { case a: System.out.print("0 "); case a-1: System.out.print("1 "); case a-2: System.out.print("2 "); } } } what is the result?

Select three corerct options from the following:

Given the following, public class If1 { static boolean b; public static void main(String [] args) { short hand = 42; if ( hand < 50 & !b ) hand++; if ( hand > 50 ) ; else if ( hand > 40 ) { hand += 7; hand++; } lse -hand; System.out.println(hand); . } what is the result

Select two correct options incase of default constructor.

Given the following, public class myprog { final static short a = 2; public static int b = 0; public static void main(String [] args) { for (int c=0; c < 4; c++) { switch (c) { case a: System.out.print("0 "); default: System.out.print("def "); case a-1: System.out.print("1 "); break; case a-2: System.out.print("2 "); } } } } what is the result?

Given the following, public class myprog { static boolean x1, x2; public static void main(String [] args) { int a = 0; if ( !x1 ) { if ( !x2 ) { x1 = true; a++; if ( 5 > 6 ) { ++; if ( !x1 ) a = a + 10; else if ( x2 = true ) a = a + 100; else if ( x1 | x2 ) a = a + 1000; } } System.out.println(a); } what is the result?

Given the following, public class myprog { public void loop() { int a= 0; while ( 1 ) { System.out.print("a plus one is " + (a + 1)); } } } Which statement is true?

Given the following, class myprog { public void test() { ---------------------------- System.out.println("a = "+ a); } } } and the following output, a = 0 a = 1 which two lines of code (inserted independently) will cause this output?

Given the following, public class Test { public static void main(String [] args) { int A = 1; do while ( A < 1 ) System.out.print("A is " + A); while ( A > 1 ) ; } } what is the result?

Given the following, int A = 0; uter: while (true) { A++; inner: for (int b = ; b < 10; b++) { Self Test 67 A += b; if (b == 3) continue inner; break outer; } continue outer; } System.out.println(I); what is the result?

Given the following, int x = 0; label: if (x < 2) { System.out.print("x is " + x); x++; continue label; } what is the result?

Given the following, System.out.print("Open "); try { System.out.print("Hello This is my first Exception programe "); throw new FileNotFoundException(); } System.out.print(" Catch Here "); catch(EOFException e) { System.out.print("EOF exception"); } catch(FileNotFoundException e) { System.out.print("File not found"); } And given that EOFException and FileNotFoundException are both subclasses of IOException, and further assuming this block of code is placed into a class, which statement is most true concerning this code?

What result come when we compile and run following code: class Test { public void foo() { System.out.println("Basic Info"); } } public class R4RSCJPTest extends Test { public static void main(String args[]) { Test t = new R4RSCJPTest(); t.foo(); } public void foo() { System.out.println("Check your skill with R4RSCJPTest"); } }

What result come when we compile and run following code: class Parent { public int foo(int l) { return l * 5; } } public class Child extends Parent { public static void main(String args[] ) { Child c = new Child(); long l = c.foo(6); System.out.println("l is " + l); } public long foo(int l) { return l * 4; } }

Given the following, public class MyProg { public static void main(String args[]){ try { System.out.print("WELCOME TO MY WORLD "); } finally { System.out.println("Finally executing "); } } } what is the result?

Given the following, import java.io.*; public class MyProgram { public static void main(String args[]){ FileOutputStream out = null; try { out = new FileOutputStream("test.txt"); out.write(122); } catch(IOException io) { System.out.println("IO Error."); } finally { out.close(); } } } and given that all methods of class FileOutputStream, including close(), throw an IOException, which of these is true?

Given the following, public class MyProg{ public static void throwit() { throw new RuntimeExcep(); } public static void main(String args[]){ try { System.out.println("Hello welcome to my world "); throwit(); System.out.println("Done with try block "); } finally { System.out.println("Finally executing "); } } } which answer most closely indicates the behavior of the program?

Given the following, public class RTExcept { public static void throwit () { System.out.print("throwit "); throw new RuntimeException(); } public static void main(String [] args) { try { System.out.print("hello "); throwit(); } atch (Exception re ) { System.out.print("caught "); } finally { System.out.print("finally "); } System.out.println("after "); } } what is the result

Select correct options to describe the following code: public class R4RSCJPTest { public int getSize() { return size; } public void setSize(int s) { size = s; } public int size; }

Which of the following statements is true?

Which two of the following statements are true?

Given the following, public class Test { public static int b; public static void foo(int a) { System.out.print("foo "); b = a; } public static int bar(int c) { System.out.print("bar "); return b = c; } public static void main(String [] args ) { int x = 0; assert x > 0 : bar(7); assert x > 1 : foo(8); System.out.println("done "); } } what is the result?

Which two of the following statements are true?

Given the following, public class myprog { public static int a; public static int foo(int b) { return b * 2; } public static void main(String [] args) { int c = 5; assert c > 0; assert c > 2: foo(c); if ( c < 7 ) assert c > 4; switch (c) { case 4: System.out.println("4 "); case 5: System.out.println("5 "); default: assert c < 10; } if ( c < 10 ) assert c > 4: c++; System.out.println(c); } } which line is an example of incorrectly use of assertions?

Select correct option to describe the following code: class Test { public int foo; } public class R4RSCJPTest extends Test { private int boo; public void setBoo(int b) { boo = b; } }

Benefits of Encapsulation

Select correct options from the followings:

IS-A Relationships

HAS-A Relationship

Overridden Methods

Select correct advantages of encapsulation from the followings:

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { A a = new B(); } } class A { public A() { super(); System.out.println("Test A"); } } class B extends A { public B() { System.out.print("Test B"); } }

What benefits do we gain from encapsulation?

What is the object-oriented relationship between a tree and an oak?

What result come when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { A a = new B(); } } class A { public A() { super(); System.out.println(" Test A"); } } class B extends A { public B() { System.out.println(" Test B"); super(); } }

What is the object-oriented relationship between a city and a road?

Invoking a Superclass Version of an Overridden Method

Select correct statements about constructor from followings:

What result come when we compile and run following code: public class R4RSCJPTest { static int x; public static void main(String args[]) { new R4RSCJPTest(8L); } public R4RSCJPTest(int i) { System.out.print(" " + (i += 3)); } public R4RSCJPTest(long i) { this(); x=(int)i; System.out.print(" " + (i)); } public R4RSCJPTest() { this(x); System.out.print(" No_Agument "); } }

What result come when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { new R4RSCJPTest(); } public void R4RSCJPTest(int i) { System.out.print(" " + (i *= 2)); } public void R4RSCJPTest(long i) { System.out.print(" " + i); } public void R4RSCJPTest() { System.out.print(" No_Agument "); } }

What result come when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { new R4RSCJPTest(); } public R4RSCJPTest(int i) //1 { System.out.print(" " + (i *= 2)); } public void R4RSCJPTest(long i) //2 { System.out.print(" " + i); } public R4RSCJPTest() //3 { System.out.print(" No_Argument "); } }

Overloaded Methods

Give the list of Illegal Override Code

Legal Overloads

Invoking Overloaded Methods

Polymorphism in Overloaded and Overridden Methods

Give the list of Method Invocation Code

Give the list of Overloaded Method

Constructor Basics

Constructor Chaining

Rules for Constructors

determine if a default constructor will be created.

What happens if the super constructor has arguments?

Overloaded Constructors

Legal Return Types

Return Types on Overloaded Methods

Overriding and return types

returning a value

What benefits do you gain from encapsulation?

Select three correct code fragments that we inserted in Object test1(), doesn't give any compile time error in following code: class R4RSCJPTest { public static void main(String args[]) { R4RSCJPTest test = new R4RSCJPTest(); Object o = test.test1(); } Object test1() { //insert code here } }

Select two correct options.That when we insert in following code compile time error comes: class R4RSCJPTest { public static void main(String args[]) { int i; } long test( int i, float j) { //insert code here } }

Given the following, public class myprog { public int getHeight() { return height; } public void setHeight(int h) { height = h; } public int height; } which is true about the class described above?

Given the following, public class myprog extends programe { private int bar; public void setBar(int y) { bar = y; } } class programe { public int foo; } which is true about the classes escribed above?

Which is true?

Which two are not benefits of encapsulation?

Given the following, class Y extends X { int getID() { return id; } } class Z { public int name; } class X { Z z = new Z(); public int id; } which two are true about instances of the classes listed above?

Given the following, class X { public void baz() { System.out.println("X"); } } public class Y extends X { public static void main(String [] args) { X x = new Y(); x.baz(); } public void baz() { System.out.println("Y"); } } what is the result?

Given the following : class Foo { String doStuff(int a) { return "hello Its my programe "; } } which method would not be legal in a subclass of Foo?

Given the following, class myprog { public int doStuff(int a) { return a * 2; } } public class ChildClass extends ParentClass { public static void main(String [] args ) { ChildClass cc = new ChildClass(); long a = cc.doStuff(7); System.out.println("a = " + a); } public long doStuff(int a) { return a * 3; } } What is the result?

R4R provides free online tutolrails ,examples for Freshers and experts .We cover core java, tutorials, spring, Hibernate, python, struts, struts 2,c language, spring boot,PHP,MYSQL,C#,ASP.NET,WPF,WCF,Photoshop , JSP, programming, example, Interview questions and answer