Skip to main content

Java objective question for written Test | Java written test objective question

                               Java objective question
All the best important question
------------------------------------------------------------------------
1.



Answer: Illegal combination of final and abstract class


2.

Answer: 4

3.



Answer:  error: bad operand types for binary operator '=='
                System.out.println("Helo"+10==10);

4.





Answer:  error: integer number too large
                System.out.println(08);


Q5.
====
 class Nit {

public static void main(String[] args) {
m1(2);
}
public static void m1(int i) {
if (i >= 0) {
m1(i - 1);
}
System.out.println(" " + i);
}}




output:
 -1
 0
 1
 2
==================================
Q.2
------
 Question 2: What will be the output of this program:
public class nit1 {
public static void main(String args[]) {
int array[] = new int[10];
for (int i = 0; i < 10; ++i) {
array[i] = i;
System.out.print(array[i] + " ");
i++;
} }}

Output:

0,2,4,6,8

================================
Q.3

Question 3: What will be the output of this program:
public class Array {
public static void main(String args[]) {
int array[][] = new int[3][];
array[0] = new int[1];
array[1] = new int[2];
array[2] = new int[3];
int sum = 1;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
array[i][j] = j + 1;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
sum += array[i][j];
System.out.print(sum);
}
}

Output:

  11

  ===============================
Q.4

Question 4: What will be the output of this program:
public class Array1 {
public static void main(String args[]) {
char array[] = new char[10];
for (int i = 0; i < 10; ++i) {
array[i] = 'i' + 5;
System.out.print(array[i] + "");
}}}
A) 1 2 3 4 5 6 7 8 9 10  B) 0 1 2 3 4 5 6 7 8 9 10
C) i i i i i i i i i i  D)None Of These

Output:  nnnnnnnnnnnnnnnnnnnnnn
==========================


Q.5
Question 5: What will be the output of this program:
import java.util.*;
public class array2 {
public static void main(String args[]) {
int[] inputArr = { 0, 10, 43, 27, 0, 59, 191, 0 };
int counter = 0;
for (int i = 0; i < inputArr.length; i++) {
if (inputArr[i] != 0) {
inputArr[counter] = inputArr[i];
counter++;
}}
while (counter < inputArr.length) {
inputArr[counter] = 0;
counter++;
}
System.out.println(Arrays.toString(inputArr));
}}

Output:


[10, 43, 27, 59, 191, 0, 0, 0]


Q.6
============================
Question 6: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = new String("hello");
String s2 = new String("helloW");
System.out.println(s1 = s2);
}}
A) True  B)False   C)HelloW   D)hello

Output:
  hellow




=================================

Question 7: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = new String("hello");
String s2 = new String(s2);
System.out.println(s1 == s2);
}
}
A) False   B)True   C) 0   D)CE

Output:
  Variable s2 might be initialized Compile-time error
===============================




Question 8: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = "hello";
String s2 = "hello";
System.out.print(s1 == s2);
System.out.print(" " + s1.equals(s2));
}


A)  False True     B)False False     C)  True True    D)True  False

Output:

  true  true


==================================


Question 9: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = "hello";
String s2 = "hello";
System.out.print(s1.charAt(0) > s2.charAt(0));
}
}
A)  False             B)True                C)  0               D)CE


Output:

  False


==================================


Question 10: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = "hello";
int i2 = 9;
System.out.print(s1 + i2);
}
}
A)  CE            B)True                C)  False              D)hello9      E)9hello
Output: hello9











Comments

Popular posts from this blog

Difference between Traditional programming languages and object-oriented programming languages..?

 What are Traditional programming languages and object-oriented programming languages..? or Difference between Traditional programming language  and object-oriented programming language Here....what is Traditional programming language and object-oriented programming language..? or Difference between Traditional programming language to help you make the new concepts, you are learning            as a beginner to  become a Master in any programming it's really very most important: Traditional programming language 1.Traditional computer programming has been around for more than a      century, with the first known computer program dating back to the mid-1800s.  2.Traditional Programming refers to any manually created program     that uses input data and runs on a computer to produce the output. 3.But for decades now, an advanced type of programming has revolutionized     business, particularly in ...

Top 50 HTML Interview Question (Most popular in the interview) | important html interview question

😀  Hello everyone. As you all know that to build a software project there are 3 Major categories to develop.😂 1.Front End  2.Middle Ware 3.Back End To crack the interview in front-end technology am going to give top FAQs which take place in your interview.so... Let's start now. TOPMOST FAQ's IN HTML   The first question raised by the interviewer is 1)What is HTML? HTML is a HyperText Markup Language. It is used for the creation and display of attractive, interactive, and dynamic web pages. By Tim Berners Lee's father of web environment. 2)What is the importance of Doctype in HTML? ​It is written at the top of the HTML document.​It is not a tag.​It tells the browser about the HTML version. 3)Define a TAG. ​A Tag or Element is said to be the text placed between Left angular brace " <" and right angular brace " >".   Syntax :   < .......... >    :     < html>   Do you know there are two types of ...

Miner Project | Major project for college Students | B.E, MCA, B-tech Student project in college

                        Miner Project | Major project college  Student for majors and miner project to submit the college and university. we can submit this project to final year students and third-year also?     Download project