
Software Programming : Java Programming QUESTIONS AND ANSWERS :: part12 : 11 to 15
Following Software Programming language Entrance Multiple choice objective type questions and answers will help you in Software Programming 2024 examinations :
11.What is the printout of the third println statement in the main method? public class Foo { int i; static int s; public static void main(String[] args) { Foo f1 = new Foo(); System.out.println("f1.i is " + f1.i + " f1.s is " + f1.s); Foo f2 = new Foo(); System.out.println("f2.i is " + f2.i + " f2.s is " + f2.s); Foo f3 = new Foo(); System.out.println("f3.i is " + f3.i + " f3.s is " + f3.s); } public Foo() { i++; s++; } } |
| f3.i is 1 f3.s is 1 |
| f3.i is 1 f3.s is 2 |
| f3.i is 1 f3.s is 3 |
| f3.i is 3 f3.s is 1 |
| f3.i is 3 f3.s is 3. |
12.What is the printout of the second println statement in the main method? public class Foo { int i; static int s; public static void main(String[] args) { Foo f1 = new Foo(); System.out.println("f1.i is " + f1.i + " f1.s is " + f1.s); Foo f2 = new Foo(); System.out.println("f2.i is " + f2.i + " f2.s is " + f2.s); Foo f3 = new Foo(); System.out.println("f3.i is " + f3.i + " f3.s is " + f3.s); } public Foo() { i++; s++; } } |
| f2.i is 1 f2.s is 1 |
| f2.i is 1 f2.s is 2 |
| f2.i is 2 f2.s is 2 |
| f2.i is 2 f2.s is 1 |
| f2.i is 0 f2.s is 1. |
13.What is wrong in the following code? class TempClass { int i; public void TempClass(int j) { int i = j; } } public class C { public static void main(String[] args) { TempClass temp = new TempClass(2); } } |
| The program has a compilation error because TempClass does not have a default constructor |
| The program has a compilation error because TempClass does not have a constructor with an int argument |
| The program compiles fine, but it does not run because class C is not public |
| The program compiles and runs fine |
| All of the above. |
14.What code may be filled in the blank without causing syntax or runtime errors? public class Test { java.util.Date date; public static void main(String[] args) { Test test = new Test(); System.out.println(_________________); } } |
| Test.date |
| Date |
| Test.date.toString() |
| Date.toString() |
| Date.test. |
More Java Programming QUESTIONS AND ANSWERS available in next pages
-
Health is the greatest gift, contentment is the greatest wealth -Buddha
- TNTET 2021 - Practice
- SSC CGL 2021 - Practice
- TNPSC Group 2A 2021 - Practice
- IIT JEE
- IIT JEE Q&A
- TNPSC Answer Keys
- TNPSC Group 2 Syllabus
-
TNPSC Q&A

- Online Tests - TNPSC
- Online Tests - GK
- IBPS 2020-2021
- Online Tests - Bank
- Online Tests - RRB NTPC
- Online Tests - UGC NET
- Online Tests - TANCET
- Online Aptitude Test
-
Engineering

-
Programming

-
Basic Science

-
Quiz

- Plus Two Question Papers
- SSLC Question Bank
-
Aptitude Tests

-
Logical Reasoning

-
General Knowledge-Hindi

-
Indian History MCQ

-
Indian Geography MCQ

-
Indian Civics MCQ

-
Indian Economics MCQ

-
CTET Biology MCQ

-
CTET Chemistry MCQ

-
CTET Physics Solved MCQ

-
Arithmetic Tests

- Press Release
- FAQ
- Coaching Centres
- TNPSC Group 1 Syllabus
-
TNPSC Group IV Syllabus

- TRB 2017 in English PDF

- TRB 2017 in Tamil PDF

- TET
- TNTET
