Which of these type parameters is used for a generic class to return and accept a number?
Predict the output of the following Java code.
Which of these is a method to clear all the data present in output buffers?
public class abekus
{
public static void main(String[] args) {
String temp = "+50";
int a = Integer.parseInt(temp);
System.out.println(a);
}
}
//Topic:- Type Casting
class abekus {
public static void main (String[] args) {
double mydouble=2.8475;
int myint=(int) mydouble;
System.out.println(myint);
}
}
What are the main advantages of using generic collections?
What is the output of the following Java code?
//Predict the output
import java.util.Scanner;
public class MyClass
{
public static void main(String args[])
{
StringBuffer str = new StringBuffer("currentnews");
System.out.println(" " + str.substring(4));
}
}
What will be the output of the program?
class Test
{
public static void main(String [] args)
{
int x= 0;
int y= 0;
for (int z = 0; z < 5; z++)
{
if (( ++x > 2 ) || (++y > 2))
{
x++;
}
}
System.out.println(x + " " + y);
}
}
Predict the output of the following Java code.
class Abekus {
int a = 1;
void func() {
demo obj = new demo();
obj.display();
}
class demo {
int b = 2;
void display() {
System.out.println("a = " + a);
}
}
void get() {
System.out.println("b = " + b);
}
}
class Abekusmain {
public static void main(String[] args) {
Abekus obj = new Abekus();
obj.func();
obj.get();
}
}
What will be the output of the program?
class SC2
{
public static void main(String [] args)
{
SC2 s = new SC2();
s.start();
}
void start()
{
int a = 3;
int b = 4;
System.out.print(" " + 7 + 2 + " ");
System.out.print(a + b);
System.out.print(" " + a + b + " ");
System.out.print(foo() + a + b + " ");
System.out.println(a + b + foo());
}
String foo()
{
return "foo";
}
}