Software Programming : Java Programming QUESTIONS AND ANSWERS :: part18 : 6 to 10
Following Software Programming language Entrance Multiple choice objective type questions and answers will help you in Software Programming 2024 examinations :
6.Given the code below: class A { public void print() { System.out.println("hi"); } } class B extends A { public void print() { System.out.println("bye"); } } What does each of the following code samples do: A a = new B(); a.print(); |
Prints nothing |
Prints “hi” |
Prints “bye” |
The code does not compile, the compiler returns a type error |
The code throws a runtime exception. |
7.What is the output of the following code? class Arithmetic { public static void main (string args[]) { int x=17, y=5; System.out.println(“x =” +x); System.out.println(“y =” +y); System.out.println(“x+y=” +(x+y)); System.out.println(“x-y=” +(x-y)); System.out.println(“x*y=” +(x*y)); System.out.println(“x/y=” +(x/y)); System.out.println(“x%y=” +(x%y)); } } |
5, 17, 12, 85, 3, 2 |
17, 5, 22, 12, 85, 3, 2 |
17, 5, 20, 21, 85, 3, 2 |
2, 3, 85, 12, 22, 5, 17 |
17, 5, 12, 22, 85, 2, 3. |
8.Suppose we now wish to print the balance information for an account with the following code: Account myAccount = new OverdraftAccount(5, 10); myAccount.printBalance(); Which of the following statement is true? |
The printed output is the string “Account” |
The printed output is the string “OverdraftAccount” |
The printed output is the string “Account: $5” |
The printed output is the string “OverdraftAccount: $5” |
There will be a compilation error because OverdraftAccount, the run-time type of myAccount, does not define the printBalance() method. |
9.class Relational{ public static void main (string args[]) { int x=7, y=11, z=11; System.out.println(“y<=z =” +(y<=z)); } } |
y<=z = 0 |
y<=z = 1 |
y<=z = true |
y<=z = false |
y |
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